Constructing the all important connection string

Kango

Solid State Member
Messages
13
For any of your new coders needing to create the connection string to the database.

http://dbtutorials.com/connect/Constructing the all important.aspx

Constructing the all important connection string


How to connect via an IP address:

Connection string formats will vary depending on the data source. Connecting by IP Address is very common and easy to use. Below is the connection string using the IP of the database server to connect to.

Data Source=100.100.100.1,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.

Connecting to a SQL Server instance:
The syntax of specifying the server instance in the value of the server key is the same for all connection strings for SQL Server.

Server=myServerName\theInstanceName;Database=myDataBase;Trusted_Connection=True;

Trusted Connection from a CE device:
Often a Windows CE device is not authenticated and logged in to a domain. To use SSPI or trusted connection / authentication from a CE device, use this connection string.

Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;User ID=myDomain\myUsername;Password=myPassword;

Note that this will only work on a CE device
 
Back
Top Bottom