3

I have the connection string:

  <connectionStrings>
    <add name="SolrLocal" providerName="System.Data.SqlClient" connectionString="Data Source=.\SQLExpress;Initial Catalog=SpeedOfLightRailDB;Integrated Security=true" />
  </connectionStrings>

But I'm getting the 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. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)"

This is my first time playing with SQL Server Express so I might be missing something obvious....

Can anyone at least confirm that this is what the connection string should look like for Entity Framework -> SQL Sever Express? I've been changing it around trying to get it to work.

4
  • 1
    Please make sure if MS SQL Server service is running. To do that just go to Control Panel > Administrative Tools > Services and try to find 'sql...' service. make sure if have status "Running". Another tip is use you network machine's name instead of dot for data source field, example:"Hardworker\sqlexpress;..." Commented Feb 28, 2016 at 3:20
  • Can you connect to .\SQLExpress on that box via SSMS? Commented Feb 28, 2016 at 3:39
  • Is your web server on the same server as the SQL Server? Commented Feb 28, 2016 at 23:18
  • Connecting with SSMS is a no go Commented Mar 10, 2016 at 2:35

3 Answers 3

2
  1. Check your windows services and make sure that the sql server express windows service is running. You can get to services by running services.msc from the RUN command bar (windows key + R). If it is not running then start it.
  2. Do you have Sql Server Management Tools installed? If so you can try to connect using those tools. If you cant connect to your sql server express instance from there, most likely you will not be able to connect from code either. If you do not have this installed no worries, you can still test it with the next step.
  3. If you need help building the connection string this next one is a great way to do it. Create a text file on your desktop. Rename the extension from .txt to .udl. Open the file and you will get a Data Link Properties screen, start with the 1st tab (it defaults to tab 2) and then fill in the second one also. Once you test your connection here and it works you can open the file using NotePad or rename the extension back to .txt and open it in NotePad. The connection string will be on the 2nd line in the text file. Just copy and paste it to your .config file.

If none of this works then report back with what you have found and any errors you are getting.

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

3 Comments

Under services, there's SQL Server (SQLEXPRESS) and SQL Server Agent (SQLEXPRESS), but trying to Start the former gives me an error: "Windows could not start the SQL Server (SQLEXPRESS) on Local Computer. For more info, review the System Event Log...."
Far as I can tell, from eventvwr.exe, the error it's referring to might be: "Initializing the FallBack certificate failed", but there's a few other SQLEXPRESS errors in the log too
@RJB - I found SQL Server not starting - FallBack certificate initialization failed on an MSDN forum. Can you see if this answer helps resolve the service not starting?
1

You are using .\SQLExpress and I think your local servername is different. What you can do is open your SQL Server and then while connecting see the server name used. You must enter the same name in your web config. Refer the below image which shows the server name while connecting to the SQL server, In my case I need to replace .\SQLExpress with RAJSHEKAR-PC\SQLEXPRESS

enter image description here

6 Comments

. and localhost both mean 'connect to the local host'. It is not necessary to put a host name in.
It depends on how the installation was done. During installation we can set it to . or localhost or A host name, It will never connect by just saying . and localhost only because of the fact that it's installed in your local machine. It is installation dependent
nonsense. if you go into cmd and type ping localhost you'll find that it pings your local pc. They all resolve to the same thing.
But yes it certainly is installation dependent. If they changed the default instance name from SQLExpress to myinstance then the server name would have to be localhost\myinsance
Possibly because your web server is on a different server. So in that case you need to use the fully qualified name. So you could be completely correct if the OP's web server is on a different server but he hasn't given us any clues.
|
1

Try this:

<connectionStrings>
    <add name="SolrLocal"
        providerName="System.Data.SqlClient"
        connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=SpeedOfLightRailDB;Integrated Security=True;MultipleActiveResultSets=True"/>
</connectionStrings>

Also check if .\SQLEXPRESS is accessible from SQL Server Management Studio, and if SQL Server is configured to allow remote connections in SQL Server Configuration Manager.

enter image description here

It can be launched from cmd like this: C:\Windows\SysWOW64\mmc.exe /32 C:\Windows\SysWOW64\SQLServerManager12.msc

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.