You can optionally specify a specific port number.
The following code samples demonstrate how to use the value of the server parameter to specify various network libraries: Use the Code Sample with Various Network Libraries The connection string and particularly the value of the server parameter: string sCxn = "server=myServer Integrated Security=SSPI database=northwind" ") Ĭonsole.WriteLine("SQL Error Number: " + e.Number) Ĭonsole.WriteLine("SQL Error Message: " + e.Message) SqlDataAdapter sqlDa = new SqlDataAdapter(sCmd, cxn) Ĭonsole.WriteLine("Hit ENTER to continue. SqlCommand sqlCmd = new SqlCommand(sCmd, cxn) String sCmd = "SELECT net_library from sysprocesses where cxn = new SqlConnection(sCxn) string sCxn = "server=lpc:myServer Integrated Security=SSPI database=master" string sCxn = "server=rpc:myServer Integrated Security=SSPI database=master" string sCxn = "server=tcp:myServer Integrated Security=SSPI database=master" string sCxn = "server=np:myServer Integrated Security=SSPI database=master" String sCxn = "server=myServer Integrated Security=SSPI database=master" The connection string has the same format irrespective of the language that you use: using System NET code sample demonstrates how to set the connection string. Original product version: SQL Server Original KB number: 313295 Code Sample This behavior can be useful when you are testing and troubleshooting connectivity issues for SQL Server.įor example, you can use the Osql command-line utility to connect to SQL Server and to force it to use the TCP/IP network library: osql -Stcp:myServer,portNumber -E Therefore, you can specify a specific client access library when you are prompted by an application for a server name to which to connect. In Microsoft Data Access Components (MDAC) 2.6 and later, you can specify the client access library by using the server name parameter in connection string. This article describes how to programmatically specify the client network library in the connection string when you connect to a SQL Server database.