1

Could someone please help me in finding the correct SQL Connection String to connect to my database in C#. The database I wish to connect to is shown in the following screenshot from SQL Management Studio

image

4
  • 3
    Have you tried connectionstrings.com Commented Jan 3, 2014 at 21:59
  • Try here: SQL Server connection strings Commented Jan 3, 2014 at 21:59
  • These are just your instances of SQL Server, you'll need to know the actual database names/servers/credentials in order to build a connection string. Commented Jan 3, 2014 at 21:59
  • Make sure that you have internet connection that allows you to connect to port 1433. Ones I was working from Starbucks and I couldn't connect to the sql server. Commented Jan 3, 2014 at 22:06

3 Answers 3

4

You can store your connection strings in you web.config or app.config file. I have placed an example string in a snippett here:

<configure>
<connectionStrings>
<add name="YOURDESIREDCONNECTIONSTRINGNAME" connectionString="Data Source=IPADDRESSorURL;Initial Catalog=DATABASENAME;User ID=YOURUSERNAME;Password=YOURPASSWORD" providerName="System.Data.SqlClient" />
  </connectionStrings>
</configure>

In your scenario, you are using SQL Express so use the following:

Data Source=.\SQLEXPRESS;

As far as you have described the question, this is the best answer I can give at the moment. I hope this helps and let me know if you have any questions.

Sign up to request clarification or add additional context in comments.

1 Comment

The most helpful answer, in light of the C# tag, on the question.
2

The instance of SQL Server that you have highlighted is SQL Server Express which is either connected to using:

.\sqlexpress

or

SERVERNAME\sqlexpress

You can try:

Server=.\sqlexpress;Database=YOURDATABASENAME;User Id=YOURSQLUSERNAME;Password=YOURSQLUSERPASSWORD;

or

Server=.\sqlexpress;Database=YOURDATABASENAME;Trusted_Connection=True;

As others have said take a look at http://www.connectionstrings.com/sql-server/ for further reference on sql server connection strings.

Comments

0

This site contains everything you need: http://www.connectionstrings.com/sql-server/. In your case server addres is .\sqlexpress or serverName\sqlexpress.

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.