Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
WorkstationId Property

SqlConnection.WorkstationId Property

Gets a string that identifies the database client.

[Visual Basic]
Public ReadOnly Property WorkstationId As String
public string WorkstationId {get;}
public: __property String* get_WorkstationId();
public function get WorkstationId() : String;

Property Value

A string that identifies the database client. If not specified, the name of the client computer. If neither is specified, the value is an empty string.


The string typically contains the network name of the client. The WorkstationId property corresponds to the Workstation ID connection string property.


[Visual Basic, C#, C++] The following example creates a SqlConnection and displays some of its read-only properties.

[Visual Basic] 
Public Sub CreateSqlConnection()
    Dim myConnectString As String = "Persist Security Info=False;Integrated Security=SSPI;database=northwind;server=mySQLServer"
    Dim myConnection As New SqlConnection(myConnectString)
    MessageBox.Show("ServerVersion: " & myConnection.ServerVersion & ControlChars.Cr & _
                    "Version: " & ControlChars.Cr & _
                    "WorkstationId: " & myConnection.WorkstationId)
End Sub 'CreateSqlConnection

public void CreateSqlConnection() 
    string myConnectString = "Persist Security Info=False;Integrated Security=SSPI;database=northwind;server=mySQLServer";
    SqlConnection myConnection = new SqlConnection(myConnectString);
    MessageBox.Show("ServerVersion: " + myConnection.ServerVersion + "\nVersion: " +
                    "\nWorkstationId: " + myConnection.WorkstationId);

void CreateSqlConnection() 
    String* myConnectString = S"Persist Security Info=False;Integrated Security=SSPI;database=northwind;server=mySQLServer";
    SqlConnection* myConnection = new SqlConnection(myConnectString);
    MessageBox::Show(String::Format( S"ServerVersion: {0}\nVersion: \nWorkstationId: {1}",
       myConnection->ServerVersion, myConnection->WorkstationId ));

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

SqlConnection Class | SqlConnection Members | System.Data.SqlClient Namespace

© 2015 Microsoft