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 连接字符串 属性。

适用于

另请参阅