4

I have a SQL Server database located at http://192.168.10.3/MyDB. I have created a C# MVC application, and I need to know the steps to connect my application to the above database.

Is it only replacing the connection string in the web.config file ?

Data Source=?? ;Initial Catalog=??;Integrated Security=SSPI;
User ID=??;Password=pwd;

If so what am I to replace where I have placed the ?? sign ?

4 Answers 4

5
  • DataSource = 192.168.10.3
  • Initial Catalog = MyDB
  • User ID = whatever sql login you are using to access your SQL Server
  • Password = password for the sql login above
Sign up to request clarification or add additional context in comments.

2 Comments

So i need not do anything else, but only just replace these values ?
Yup. There are other settings you could add but that is all a basic connection string requires.
3

The other answers here are good. In addition, ConnectionStrings.com can be your friend, especially if you are going to connect to various types of databases in the future. Select the database that you need to connect to and then you'll see the different connection strings you can use for that database.

http://connectionstrings.com/sql-server-2012#sqlconnection

Comments

1

you can try this

  1. create a new text document on your desktop - conn.txt
  2. change file extension to udl (conn.udl)
  3. double click to open the file in the first tab select appropriate provider 4 . in the second tab enter server name (ip address,port), username, password (check Allow saving password) and database name.
  4. test connection
  5. if the test reports success close the window.
  6. open the file with notepad, copy everything but the provider name and paste it back to connectionString

Comments

0

Below is connection string you need for:

Data Source="192.168.10.3" ;Initial Catalog=MyDb;Integrated Security=SSPI; User ID=sa (for example);Password=whatever you set before;

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.