2013-03-26 74 views
1

请帮助我。我得到这个错误:错误:在VS2010中尝试访问集成数据库中的数据时出现错误:

'/'应用程序中的服务器错误。

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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

源错误:

Line 29:    SqlConnection con = new SqlConnection(conStr); 
Line 30:    SqlCommand cmd = new SqlCommand("Select * from SingUp", con); 
Line 31:    con.Open(); 
Line 32:    using(con) 
Line 33:    { 

Source File: C:\Users\My\Documents\Visual Studio 2010\myproject1\Asad\PostAvertisement.aspx.cs Line: 31

+0

是您的连接字符串'conStr'有效吗? – jordanhill123 2013-03-26 08:26:58

回答

0

,这个问题可能是因为以下几个原因occure。既然你没有提到你已经尝试了什么,你可以按照这个指示;

  1. Make sure your database engine is configured to accept remote connections
  2. Check the SQL Server service account
  3. If you are using a named SQL Server instance, make sure you are using that instance name in your connection strings in your ASP.NET web application 4.You may need to create an exception on the firewall for the SQL Server instance and port you are using
  4. If you are using a named SQL Server instance, make sure you are using that instance name in your connection strings
  5. Check SQLBrowser; check that it is running. You may also need to create an exception in your firewall for SQLBrowser.
  6. Check that you have connectivity to the SQL Server. Note what you are using to connect: machine name, domain name or IP address? Use this when checking connectivity.

来源:http://www.sqlmusings.com/2009/03/11/resolving-a-network-related-or-instance-specific-error-occurred-while-establishing-a-connection-to-sql-server

相关问题