共用方式為


SqlConnection.WorkstationId 屬性

定義

取得識別資料庫用戶端的字串。

public:
 property System::String ^ WorkstationId { System::String ^ get(); };
public string WorkstationId { get; }
[System.Data.DataSysDescription("SqlConnection_WorkstationId")]
public string WorkstationId { get; }
member this.WorkstationId : string
[<System.Data.DataSysDescription("SqlConnection_WorkstationId")>]
member this.WorkstationId : string
Public ReadOnly Property WorkstationId As String

屬性值

識別資料庫用戶端的字串。 如果沒有指定,則為用戶端電腦的名稱。 如果都沒有指定,則該值為空字串。

屬性

範例

下列範例會 SqlConnection 建立 並顯示 WorkstationId 屬性。

private static void OpenSqlConnection(string connectionString)
{
    using (SqlConnection connection = new SqlConnection(connectionString))
    {
        connection.Open();
        Console.WriteLine("ServerVersion: {0}", connection.ServerVersion);
        Console.WriteLine("WorkstationId: {0}", connection.WorkstationId);
    }
}
Private Sub OpenSqlConnection(ByVal connectionString As String)
    Using connection As New SqlConnection(connectionString)
        connection.Open()
        Console.WriteLine("ServerVersion: {0}", connection.ServerVersion)
        Console.WriteLine("WorkstationId: {0}", connection.WorkstationId)
    End Using
End Sub

備註

字串通常包含客戶端的網路名稱。 屬性WorkstationId會對應至 Workstation ID 連接字串 屬性。

適用於

另請參閱