SQL server with 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 on how to connect to SQL Server.
ODBC

Standard Security

Copy codeThe Code is as follows: Driver = {SQL Server}; Server = myServerAddress; Database = myDataBase; Uid = myUsername; Pwd = myPassword;

Trusted connection

Copy codeThe Code is as follows: Driver = {SQL Server}; Server = myServerAddress; Database = myDataBase; Trusted_Connection = Yes;

Prompt for username and password
This one is a bit tricky. First you need to set the connection object's Prompt property to adPromptAlways. Then use the connection string to connect to the database.Copy codeThe Code is as follows: oConn. Properties ("Prompt") = adPromptAlways

Driver = {SQL Server}; Server = myServerAddress; Database = myDataBase;

Ole db, OleDbConnection (. NET)
Standard SecurityCopy codeThe Code is as follows: Provider = sqloledb; Data Source = myServerAddress; Initial Catalog = myDataBase; User Id = myUsername; Password = myPassword;

Trusted connection

Copy codeThe Code is 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 note that the multiple SQL Server instances feature is available only from SQL Server version 2000 and not in any previous versions.

Prompt for username and password
This one is a bit tricky. first set the connection object's 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 codeThe Code is as follows: oConn. Provider = "sqloledb"
OConn. Properties ("Prompt") = adPromptAlways

Data Source = myServerAddress; Initial Catalog = myDataBase;

Connect via an IP address

Copy codeThe Code is 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 is how to use TCP/IP instead of Named Pipes. at the end of the Data Source is the port to use. 1433 is the default port for SQL Server.
How to define which network protocol to use>

SqlConnection (. NET)

Standard Security

Copy codeThe Code is 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 is to point out that some connection string keywords have has equivalents.Copy codeThe Code is as follows: Server = myServerAddress; Database = myDataBase; User ID = myUsername; Password = myPassword; Trusted_Connection = False;

Trusted Connection

Copy codeThe Code is 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 is to point out that some connection string keywords have has equivalents.Copy codeThe Code is as follows: Server = myServerAddress; Database = myDataBase; Trusted_Connection = True;

Use serverName \ instanceName as Data Source to use a specific SQL Server instance. Please note that the multiple SQL Server instances feature is available only from SQL Server version 2000 and not in any previous versions.

Connect via an IP address

Data Source = 190.190.200.100, 1433; Network Library = DBMSSOCN; Initial Catalog = myDataBase; User ID = myUsername; Password = myPassword;

DBMSSOCN = TCP/IP. this is how to use TCP/IP instead of Named Pipes. at the end of the Data Source is the port to use. 1433 is the default port for SQL Server.
How to define which network protocol to use>

Specifying packet size

Copy codeThe Code is 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 not be optimal, try to set this value to 4096 instead.
The default value of 8192 might cause errors as well ("Failed to reserve contiguous memory"), check this out>

Data Shape

MS Data Shape

Copy codeThe Code is as follows: Provider = MSDataShape; Data Provider = SQLOLEDB; Data Source = myServerAddress; Initial Catalog = myDataBase; User ID = myUsername; Password = myPassword;

Http://www.connectionstrings.com /? Carrier = sqlserver

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.