SQL Server connection string

Source: Internet
Author: User
Tags sql server connection string sql server express

SQL native client ODBC driver

Standard secure connection

Driver = {SQL native client}; server = myserveraddress; database = mydatabase; uid = myusername; Pwd = mypassword;
 
Are you using SQL Server 2005 Express? Use the connection expression "host name \ sqlexpress" in the "server" option ".

Trusted connection

Driver = {SQL native client}; server = myserveraddress; database = mydatabase; trusted_connection = yes;
 
\ "Integrated Security = sspi \" is the same as \ "trusted_connection = Yes.

Connect to an SQL server instance
The expression of the specified server instance is the same as the connection string of other SQL servers.
Driver = {SQL native client}; server = myservername \ theinstancename; database = mydatabase; trusted_connection = yes;
 

User name and password
Oconn. properties (\ "prompt \") = adpromptalways

Driver = {SQL native client}; server = myserveraddress; database = mydatabase;
 

Use Mars (multiple active result sets)

Driver = {SQL native client}; server = myserveraddress; database = mydatabase; trusted_connection = yes; mars_connection = yes;
 
\ "Multipleactiveresultsets = true \" is the same as mars_connection = Yes.
Use ADO. NET 2.0 as the module of Mars. Mars does not support ADO. NET 1.0 and ADO. NET 1.1.

Verify Network Data

Driver = {SQL native client}; server = myserveraddress; database = mydatabase; trusted_connection = yes; encrypt = yes;
 

Connect to the local SQL Server express instance by attaching a local database file

Driver = {SQL native client}; server =. \ sqlexpress; attachdbfilename = c: \ ASD \ qwe \ mydbfile. MDF; database = dbname; trusted_connection = yes;
 
Why use database parameters? If a database with the same name has been attached, SQL server will not attach it again.

Connect to the local SQL Server express instance by attaching a database file in the local data folder

Driver = {SQL native client}; server =. \ sqlexpress; attachdbfilename = | datadirectory | mydbfile. MDF; database = dbname; trusted_connection = yes;
 
Why use database parameters? If a database with the same name has been attached, SQL server will not attach it again.

Database image
Data Source = myserveraddress; failover partner = mymirrorserver; initial catalog = mydatabase; Integrated Security = true;
 


SQL native client OLE DB Provider

Standard connection

Provider = sqlncli; server = myserveraddress; database = mydatabase; uid = myusername; Pwd = mypassword;
 
Are you using SQL Server 2005 Express? Use the connection expression "host name \ sqlexpress" in the "server" option ".

Trusted connection

Provider = sqlncli; server = myserveraddress; database = mydatabase; trusted_connection = yes; [Page]
 
\ "Integrated Security = sspi \" is the same as \ "trusted_connection = Yes \"

Connect to an SQL server instance
The expression of the specified server instance is the same as the connection string of other SQL servers.
Provider = sqlncli; server = myservername \ theinstancename; database = mydatabase; trusted_connection = yes;
 

Use account and password
Oconn. properties (\ "prompt \") = adpromptalways

Oconn. Open \ "provider = sqlncli; server = myserveraddress; database = mydatabase;
 

Use Mars (multiple active result sets)

Provider = sqlncli; server = myserveraddress; database = mydatabase; trusted_connection = yes; marsconn = yes;
 
\ "Multipleactiveresultsets = true \" and \ "mars_connection = Yes \" are the same.
Use ADO. NET 2.0 as the module of Mars. Mars does not support ADO. NET 1.0 and ADO. NET 1.1.

Verify Network Data

Provider = sqlncli; server = myserveraddress; database = mydatabase; trusted_connection = yes; encrypt = yes;
 

Connect to the local SQL Server express instance by attaching a local database file

Provider = sqlncli; server =. \ sqlexpress; attachdbfilename = c: \ ASD \ qwe \ mydbfile. MDF; database = dbname; trusted_connection = yes;
 
Why use database parameters? If a database with the same name has been attached, SQL server will not attach it again.

Connect to the local SQL Server express instance by attaching a database file in the local data folder

Provider = sqlncli; server =. \ sqlexpress; attachdbfilename = | datadirectory | mydbfile. MDF; database = dbname; trusted_connection = yes;
 
Why use database parameters? If a database with the same name has been attached, SQL server will not attach it again.

Database image
Data Source = myserveraddress; failover partner = mymirrorserver; initial catalog = mydatabase; Integrated Security = true;
 


Sqlconnection (. NET)

Standard connection

Data Source = myserveraddress; initial catalog = mydatabase; user id = myusername; Password = mypassword;
 
You can use servername \ InstanceName as the data source to specify an SQL server instance.
Are you using SQL Server 2005 Express? Use the connection expression "host name \ sqlexpress" in the "server" option ".

Posted @ jiania read (...) Comments (...) EDIT favorites

Refresh comment refresh page Back to Top

Blog homepage blog news flash programmer recruitment Knowledge Base



Copyright 2013 jiania

Related Article

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.