Why did a network-related or instance-specific err

2019-01-01 05:32发布

I'm very frustrated. I have a website running on Visual Web Developer 2008 Express with my local database, everything works great. I also have the same web site running on a production server. Everything was working great but tonight I did a "reset" on production.

  1. I deleted a couple of table, re-created them and inserted data. Everything was ok at this time.

  2. I deleted ALL the files via the FTP.

  3. I used the module called "Copy website" in visual studio and copy the site to the website via FTP.

When I log on my website, here is the error I got:

Server Error in '/' Application.

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)

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.Data.SqlClient.SqlException: 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)


Nothing has changed related to SQL connection, this is OLD code that I always used. My website is completely paralysed because of this and I feel sick inside because I feel there is nothing I can do.

Can anyone help me please?

14条回答
墨雨无痕
2楼-- · 2019-01-01 06:12

I had the same error, and it turned out .NET created a database on localhost which I wasn't aware of. When I tried to get the site live it didn't create the database, so the code was pointing to a database that was non existent.

Hopefully this might help some other people out trying to troubleshoot.

查看更多
浪荡孟婆
3楼-- · 2019-01-01 06:13

we have to enable TCP/IP property in sql server configuration manager

查看更多
查无此人
4楼-- · 2019-01-01 06:17

Your connection string was probably overriden when you copied your new website version on the server. Please check the connection string in web.config and see if it is valid.

查看更多
爱死公子算了
5楼-- · 2019-01-01 06:18

If your server was working and suddenly started erroring out, your server/instance stopped and connection settings were changed somehow.

For SQL Server 2008 here is how you can fit this:

  1. Goto Start > All Programs > SQL Server 2008 > Configuration Tools > SQL Server Configuration Manager > SQL Server Services.
    And here you'll see all the instances and their state.
  2. The state of the instance you were trying to connect can be stopped here.
  3. Double click on the instance and then click on connect.
  4. It will connect and now go back and run your application, you will be able to connect with no error.

This solution assumes the error is not being caused by something wrong in your connection string.

查看更多
孤独总比滥情好
6楼-- · 2019-01-01 06:24

I had the same problem but found that it was because the password for my Service Account for the Database Engine had expired. The solution was to login to that account, fix this, then set the account so password never expires.

查看更多
栀子花@的思念
7楼-- · 2019-01-01 06:27

In my case it was a very silly error. I was using a library to read the connection string out of a config file, and I forgot to double back slash.

For example I had: localhost\sqlexpress which was read as localhostsqlexpress when I should rather have had localhost\\sqlexpress note the \

查看更多
登录 后发表回答