SQL Server_ common tools for data connection strings

Source: Internet
Author: User
Tags how to connect to sql server
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.