2

I am working on an ASP.NET MVC project, which uses this connection string:

<add name="Name" 
     connectionString="Data Source=.;initial catalog=MyDBName;integrated security=True;multipleactiveresultsets=True;" />```

Note: the data source value is ., this works but after I reset my pc and reinstalled SQL Server, it no longer works, I get an error

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible.

until I change the . in the connection string to DESKTOP-1V12LN7\SQLEXPRESS.

My question is what does the value . in the connection string mean and why doesn't it work after reinstalling SQL Server?

1
  • . meant localhost with the default instance name. Your latest instance is named, so . on its own won't work (.\SQLEXPRESS or localhost\SQLEXPRESS would though). Commented Nov 14, 2020 at 12:00

1 Answer 1

3

The data source=. (or server=. or data source=(local), which are all equivalent) means : connect to the local machine and the default, unnamed instance of SQL Server - this is the default for all non-Express editions of SQL Server installed on your machine.

When you install SQL Server Express, by default, it doesn't get installed as the default, unnamed instance - but it uses a SQLEXPRESS instance name - so you need to change your connection string to:

  • .\SQLEXPRESS
  • (local)\SQLEXPRESS
  • DESKTOP-1V12LN7\SQLEXPRESS
Sign up to request clarification or add additional context in comments.

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.