I find it helpful to have these stored in a file so i don’t have to keep missing out silly keywords when am writing a connection string. Hope you find them handy too 🙂
Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;
Don’t forget to use SERVERNAME\INSTANCENAME as Data Source to connect to a specific SQL Server instance.
Are you using an EXPRESS Edition? use SERVERNAME\EXPRESS as Datasource
Standard Security alternative syntax
This connection string is similar the previous, just some keyword changes which means the same thing.
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 many equivalents.
Connecting to an 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.
For more about connection string visit http://www.connectionstrings.com