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

人盡茶涼 提交于 2019-12-13 01:42:43

问题


I'm just publishing my website to my domain name and when I try to access it in my browser I get the Following 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)

I think the problem is into my connection String ==>

<configuration>
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
<add name="TennisOnlineContext" connectionString="Data Source=|DataDirectory|Tennis.sdf" providerName="System.Data.SqlServerCe.4.0 " />
</connectionStrings>
...
</configuration>

Sorry but it's my first web site where I try to publish... So, please what I'm doing wrong ? Thanks in advance...


回答1:


Have you tried localhost\SQLEXPRESS? Ensure all of your connection keywords abide by those outlined by Microsoft here.

You can check if a connection string is valid, or indeed build a valid connection string that you can copy, by using the SQL/Database Connection utility that ships with VS2010. In VS2010 goto Tools, Connect to database. This will launch the connection dialog; here you can build and test connection strings. For advance connection features, once in the dialog click Advanced. From the advance dialog you can copy and paste connection strings.

Microsoft have also released this dialog to be freely used and distributed in .NET applications. If you interested in this it can be found here.

I hope this helps.




回答2:


If you are connecting from Windows machine A to Windows machine B (server with SQL Server installed), and are getting this error, you need to do the following:

On machine B:

1.) turn on the Windows service called "SQL Server Browser" and start the service

2.) in the Windows firewall, enable incoming port UDP 1434 (in case SQL Server Management Studio on machine A is connecting or a program on machine A is connecting)

3.) in the Windows firewall, enable incoming port TCP 1433 (in case there is a telnet connection)

4.) in SQL Server Configuration Manager, enable TCP/IP protocol for port 1433




回答3:


If you look into your release version of web.config you will find <roleManager enabled="false"
Change this configuration setting to True You can find details here at this link below http://dotnet1blogger.blogspot.com/2012/04/network-related-or-instance-specific.html




回答4:


please check once TCP/IP properties in SQL server configuration manager

for more details here




回答5:


Enable TCP/IP and Named Pipes in SQL Server Configuration Manager.

From SQL Server Configuration Manager, select SQL Server Network Configuration, then select the appropriate instance (if you have multiple). Right click and select enable for Named Pipes and TCP/IP.



来源:https://stackoverflow.com/questions/9911286/a-network-related-or-instance-specific-error-occurred-while-establishing-a-conne

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!