共用方式為


Users 屬性

Represents a collection of User objects. Each User object represents a user who is defined on the database.

命名空間:  Microsoft.SqlServer.Management.Smo
組件:  Microsoft.SqlServer.Smo (在 Microsoft.SqlServer.Smo.dll 中)

語法

'宣告
<SfcObjectAttribute(SfcContainerRelationship.ObjectContainer, SfcContainerCardinality.ZeroToAny,  _
    GetType(User))> _
Public ReadOnly Property Users As UserCollection
    Get
'用途
Dim instance As Database
Dim value As UserCollection

value = instance.Users
[SfcObjectAttribute(SfcContainerRelationship.ObjectContainer, SfcContainerCardinality.ZeroToAny, 
    typeof(User))]
public UserCollection Users { get; }
[SfcObjectAttribute(SfcContainerRelationship::ObjectContainer, SfcContainerCardinality::ZeroToAny, 
    typeof(User))]
public:
property UserCollection^ Users {
    UserCollection^ get ();
}
[<SfcObjectAttribute(SfcContainerRelationship.ObjectContainer, SfcContainerCardinality.ZeroToAny, 
    typeof(User))>]
member Users : UserCollection
function get Users () : UserCollection

屬性值

型別:Microsoft.SqlServer.Management.Smo. . :: . .UserCollection
A UserCollection object that represents all the users defined on the database.

備註

Specific users can be referenced by using this collection by specifying the name of the user. To add a new user to the collection, call the user constructor.

範例

'Connect to the local, default instance of SQL Server.
Dim srv As Server
srv = New Server

'Reference the AdventureWorks database.
Dim db As Database
db = srv.Databases("AdventureWorks")

'Display all the users in the database.
Dim us As User
For Each us In db.Users
   Console.WriteLine(us.Name)
Next