SQL Server connection string.

I develop a website. When I work in local machine for login/logout, The connectionstring works well.

<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\xxxxx.mdf;Initial Catalog=Restaurants;Integrated Security=True" providerName="System.Data.SqlClient" />

But When I deploy the web to IIS server. The I always can't work normally.

 

The system cannot find the file specified

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ComponentModel.Win32Exception: The system cannot find the file specified

Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[Win32Exception (0x80004005): The system cannot find the file specified] [SqlException (0x80131904): 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: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)]

What is the reason?

September 7th, 2015 11:10pm

I guess you are in the wrong forum for that... If you want to use LocalDB on a Server you should ask the question in the LocalDB forum. If this should be about another edition you want to use please specify the connection string you are actually using, because the one in your post looks like LocalDB...
Free Windows Admin Tool Kit Click here and download it now
September 7th, 2015 11:45pm

Hello,

Is the LocalDB engine installed on the machine? Is the database file (.MDF) deployed to the Server in the mentioned DataDirectory folder?

September 8th, 2015 2:40am

Hi,

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

Generally issues like this are related to any of the following need to be looked at:

1. firewall settings from the web server to the database server

2. connection string errors

3. enable the appropriate protocol pipes/ tcp-ip

Try connecting to sql server with sql management server on the system that sql server is installed on and work from there. Pay attention to information in the errorlogs.

Free Windows Admin Tool Kit Click here and download it now
September 8th, 2015 2:46am

1. Make sure SQL Server Service is running
2. If a named instance, make sure SQL Server browser service is running
3. Make sure SQL Server is configured to allow remote connections
4. Examine the SQL Server error log for messages confirming that SQL is listening on the expected network interfaces and ports
5. Test server connectivity with PING from the client machine
6. Test port connectivity using TELNET or PowerShell to the server and port (from step 4) from the client machine.  For example
a. TELNET <server-name> 1433
b. PowerShell: 1433 | % { echo ((new-object Net.Sockets.TcpClient).Connect("YourServerName",$_)) "server listening on TCP port $_" }
7. Check firewall settings if step 5 or 6 connectivity test fails
September 8th, 2015 2:51am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics