SQL Server Set Your custom connection string values
This is a compiled connection strings reference list in how to connect to SQL Server.
Odbc
Standard Security
Copy Code code as follows:
Driver={sql Server}; Server=myserveraddress;database=mydatabase; Uid=myusername; Pwd=mypassword;
Trusted Connection
Copy Code code as follows:
Driver={sql Server}; Server=myserveraddress;database=mydatabase; Trusted_connection=yes;
Prompt for username and password
This is a bit tricky. The need to set the connection object ' s Prompt property to adPromptAlways. Then Use the "connection string to connect to the" database.
Copy Code code as follows:
Oconn.properties ("Prompt") = adPromptAlways
Driver={sql Server}; Server=myserveraddress;database=mydatabase;
OLE DB, OleDbConnection (. NET)
Standard Security
Copy Code code as follows:
Provider=sqloledb;data source=myserveraddress;initial catalog=mydatabase; User Id=myusername; Password=mypassword;
Trusted Connection
Copy Code code as follows:
Provider=sqloledb;data source=myserveraddress;initial catalog=mydatabase;integrated Security=SSPI;
Use ServerName\InstanceName as Data Source to use a specific SQL Server instance. Please, that's multiple SQL Server instances feature is available only from SQL Server version revious versions.
Prompt for username and password
This is a bit tricky. The Connection object Provider property to "SQLOLEDB". Thereafter set the Connection object ' s Prompt property to adPromptAlways. Then Use the "connection string to connect to the" database.
Copy Code code as follows:
Oconn.provider = "SQLOLEDB"
Oconn.properties ("Prompt") = adPromptAlways
Data source=myserveraddress;initial catalog=mydatabase;
Connect via a IP address
Copy Code code as follows:
Provider=sqloledb;data source=190.190.200.100,1433; Network Library=dbmssocn;initial catalog=mydatabase; User Id=myusername; Password=mypassword;
Dbmssocn=tcp/ip. This are how to use TCP/IP instead of Named pipes. At the ' end of the ' the ' Data Source ' is the ' port to ' use. 1433 is the default port for SQL Server.
Define which network protocol to use >>
SqlConnection (. NET)
Standard Security
Copy Code code as follows:
Data source=myserveraddress;initial catalog=mydatabase; User Id=myusername; Password=mypassword;
Standard Security Alternative syntax
This connection string produce the same result as the previous one. The reason to include it's to point out that some connection string keywords have many.
Copy Code code as follows:
Server=myserveraddress;database=mydatabase; User Id=myusername; Password=mypassword; Trusted_connection=false;
Trusted Connection
Copy Code code as follows:
Data source=myserveraddress;initial catalog=mydatabase;integrated Security=sspi;
Trusted Connection Alternative syntax
This connection string produce the same result as the previous one. The reason to include it's to point out that some connection string keywords have many.
Copy Code code as follows:
Server=myserveraddress;database=mydatabase; Trusted_connection=true;
Use ServerName\InstanceName as Data Source to use a specific SQL Server instance. Please, that's multiple SQL Server instances feature is available only from SQL Server version revious versions.
Connect via a IP address
Data source=190.190.200.100,1433; Network Library=dbmssocn;initial catalog=mydatabase; User Id=myusername; Password=mypassword;
Dbmssocn=tcp/ip. This are how to use TCP/IP instead of Named pipes. At the ' end of the ' the ' Data Source ' is the ' port to ' use. 1433 is the default port for SQL Server.
Define which network protocol to use >>
Specifying packet size
Copy Code code as follows:
Server=myserveraddress;database=mydatabase; User Id=myusername; Password=mypassword; Trusted_connection=false; Packet size=4096;
By default, the Microsoft. NET Framework Data Provider for SQL Server sets the network packet size to 8192 bytes. This might however is optimal, try to set this value to 4096 instead.
The default value of 8192 might cause errors as OK ("Failed to reserve contiguous memory"), check this out >>
Data Shape
MS Data Shape
Copy Code code as follows:
Provider=msdatashape;data provider=sqloledb;data source=myserveraddress;initial Catalog=myDataBase; User Id=myusername; Password=mypassword;
Http://www.connectionstrings.com/?carrier=sqlserver