次の方法で共有


EnumMembers メソッド

SQL Server のインスタンスのサーバー ロールとデータベース ロールのメンバーの一覧を列挙します。

名前空間:  Microsoft.SqlServer.Management.Smo
アセンブリ:  Microsoft.SqlServer.Smo (Microsoft.SqlServer.Smo.dll)

構文

'宣言
Public Function EnumMembers ( _
    roleType As RoleTypes _
) As StringCollection
'使用
Dim instance As Server
Dim roleType As RoleTypes
Dim returnValue As StringCollection

returnValue = instance.EnumMembers(roleType)
public StringCollection EnumMembers(
    RoleTypes roleType
)
public:
StringCollection^ EnumMembers(
    RoleTypes roleType
)
member EnumMembers : 
        roleType:RoleTypes -> StringCollection 
public function EnumMembers(
    roleType : RoleTypes
) : StringCollection

パラメーター

戻り値

型: System.Collections.Specialized. . :: . .StringCollection
メンバーとメンバーが属するロールの一覧を含む StringCollection オブジェクトの値です。

説明

このメソッドを使用して、サーバー ロール、データベース ロール、またはその両方のメンバーの一覧を取得します。

使用例

C#

Server srv = new Server("(local)");
StringCollection sc = srv.EnumMembers(RoleTypes.All);
foreach (String s in sc)
{
   Console.WriteLine(s);
}

PowerShell

$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")

$sc = $srv.EnumMembers([Microsoft.SqlServer.Management.Smo.RoleTypes]::All)
foreach ($s in $sc)
{
   Write-Host $s
}