Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

SqlConnection.WorkstationId Property

Gets a string that identifies the database client.

[Visual Basic]
Public ReadOnly Property WorkstationId As String
[C#]
public string WorkstationId {get;}
[C++]
public: __property String* get_WorkstationId();
[JScript]
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.

Remarks

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

Example

[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)
    myConnection.Open()
    MessageBox.Show("ServerVersion: " & myConnection.ServerVersion & ControlChars.Cr & _
                    "Version: " & ControlChars.Cr & _
                    "WorkstationId: " & myConnection.WorkstationId)
    myConnection.Close()
End Sub 'CreateSqlConnection

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

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

[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.

Requirements

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

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.