RoleProvider.RoleExists メソッド
アセンブリ: System.Web (system.web.dll 内)

Dim instance As RoleProvider Dim roleName As String Dim returnValue As Boolean returnValue = instance.RoleExists(roleName)
戻り値
ロール名が構成済みの applicationName のデータ ソースに既に存在する場合は true。それ以外の場合は false。

RoleExists は Roles クラスの RoleExists メソッドによって呼び出され、ロール名が構成済みの ApplicationName のデータ ソースに存在しているかどうかを判断します。
指定された roleName が null 参照 (Visual Basic では Nothing) または空の文字列である場合、プロバイダから例外をスローすることをお勧めします。

RoleExists メソッドの実装サンプルを次のコード例に示します。
Public Overrides Function RoleExists(rolename As String) As Boolean If rolename Is Nothing OrElse rolename = "" Then _ Throw New ProviderException("Role name cannot be empty or null.") Dim exists As Boolean = False Dim conn As OdbcConnection = New OdbcConnection(connectionString) Dim cmd As OdbcCommand = New OdbcCommand("SELECT COUNT(*) FROM [" & rolesTable & "]" & _ " WHERE Rolename = ? AND ApplicationName = ?", conn) cmd.Parameters.Add("@Rolename", OdbcType.VarChar, 255).Value = rolename cmd.Parameters.Add("@ApplicationName", OdbcType.VarChar, 255).Value = ApplicationName Try conn.Open() Dim numRecs As Integer = CType(cmd.ExecuteScalar(), Integer) If numRecs > 0 Then exists = True End If Catch e As OdbcException ' Handle exception. Finally conn.Close() End Try Return exists End Function
public override bool RoleExists(string rolename) { if (rolename == null || rolename == "") throw new ProviderException("Role name cannot be empty or null."); bool exists = false; OdbcConnection conn = new OdbcConnection(connectionString); OdbcCommand cmd = new OdbcCommand("SELECT COUNT(*) FROM [" + rolesTable + "]" + " WHERE Rolename = ? AND ApplicationName = ?", conn); cmd.Parameters.Add("@Rolename", OdbcType.VarChar, 255).Value = rolename; cmd.Parameters.Add("@ApplicationName", OdbcType.VarChar, 255).Value = ApplicationName; try { conn.Open(); int numRecs = (int)cmd.ExecuteScalar(); if (numRecs > 0) { exists = true; } } catch (OdbcException) { // Handle exception. } finally { conn.Close(); } return exists; }

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からRoleProvider.RoleExists メソッドを検索する場合は、下記のリンクをクリックしてください。

- RoleProvider.RoleExists メソッドのページへのリンク