Patrick.SE
Patrick.SE

Reputation: 4564

Linq to SQL Connection String for Sql Auth

tI'm using Sql Server with Windows Authentication enabled. Recently I added a dropdown to allow for different connections. One of them uses SQL Authentication.

I consulted msdn and it seems all I need to do is add a Username and Password entry to my string.

http://msdn.microsoft.com/en-us/library/aa905872(v=sql.80).aspx

My windows authentication string :

Data Source=PC\Slike;Initial Catalog=db_slike_articles;Integrated Security=True

The second string I added for SQL Authentication :

Data Source=Data Source=PC\Dev;Initial Catalog=db_dev_articles;Integrated Security=True;User ID=root;Password=rootpwd

For some reason when I choose the 2nd SQL connection it's throwing an SqlException that login failed with my PC\Slike username. The connection string is the second one with the User ID and Pwd, I don't understand why it's trying to connect against my local account.

The second string is located on a remote machine, is there something I have to enable to switch from Windows Auth to Sql Auth or does specifying the the credentials within the string is enough?

Thanks

Upvotes: 1

Views: 1626

Answers (1)

Davide Piras
Davide Piras

Reputation: 44595

when using SQL Authentication, remove this from the connection string:

Integrated Security=True;

there is a web site listing all possible/supported syntax of connection strings for all database engines, I can't find it now, connectionstrings.com does not load properly.

Upvotes: 1

Related Questions