0

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

My Question

what is the connection string

I think that

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.

i am using .net framework 4

3
  • 4
    connectionstrings.com/sql-server
    – meziantou
    Mar 22, 2014 at 11:13
  • @meziantou thanks for your suggestions, I have read that website before and I want to be sure that what I have understood, which is the code I have shown, is correct. Please help Mar 22, 2014 at 11:39
  • @user3432257 So why not jus t try it out? This is a trivial thing to check - checking is faster than even writing this post here.
    – TomTom
    Mar 22, 2014 at 12:09

1 Answer 1

3

You can check that by going to Tools->Connect to Database

enter image description here

In the Add Connection dialog you'll have your server name and your db name (or add it) and click the Advanced button

enter image description here

In the Advanced Properties dialog copy the string marked below:

enter image description here

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

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.