Reputation: 415
I have a database called MyDatabase
exists in sql server 2008 r2
on windows server 2003
I want to test my website on that server using Windows Authentication
what is the connection string
connectionString="Initial Catalog=MyDatabase;Data Source=localhost;Integrated Security=SSPI;"/>
But I don't know if it is correct. Also, I can't try because I have to give the code to my manager, I need to be everything perfect when I gave them.
Upvotes: 0
Views: 1675
Reputation: 3750
You can check that by going to Tools->Connect to Database
In the Add Connection dialog you'll have your server name and your db name (or add it) and click the Advanced button
In the Advanced Properties dialog copy the string marked below:
This will be your string, in this case:
SqlConnection con = new SqlConnection("DataSource=MCA\\LENOVO;Initial Catalog=DecryptTesting;Integrated Security=True");
Make sure you add one more slash "\" like above or an "@" to a connection. You need to escape the backward slash \ in your connection string or use the "@" symbol if you want to avoid escaping characters in your string:
SqlConnection con = new SqlConnection(@"DataSource=MCA\LENOVO;Initial Catalog=DecryptTesting;Integrated Security=True");
EDIT: DataSource is the name of your server, Initial Catalog is your database
Hope this helps
Upvotes: 3