[DotNet]Sql Server connection string format

I found myself always forget the connection string format. this is a memo for it.

1. User Id and password style

Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;

Initial Catalog can also be replaced by database

2. User Id and password with Trusted_Connection

Server=myServerAddress;Database=myDataBase;User ID=myUsername;Password=myPassword;Trusted_Connection=True;

Trusted_Connection=True is equlvalent to Integrated Security=SSPI or Integrated Security=true.

If Trusted_Connection=True is provided, User ID and Password will be ignored.

3. The prefered format



blog comments powered by Disqus