日期:2014-05-17  浏览次数:21022 次

数据库无法连接,怎么做?
我的VS是2012,我机器上的SQL Serve是 2008,
我试图连接数据库的时候,发生这样的异常:
/*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)
*/

怎么解决哈...

------解决方案--------------------
把你连接的代码贴一下吧。

------解决方案--------------------
检查你的实例名是否正确 SQL Server是否允许远程连接
------解决方案--------------------
"Data Source=localhost;Initial Catalog=DB_Person;User ID=sa;Password=***;"

试试这个

确定你的sql server服务没有被关掉吧。
------解决方案--------------------
现在vs里连接一下数据库 看看 通不通

------解决方案--------------------
(1)首先检查配置,通过你的错误提示来看,是配置的问题 that SQL Server is configured to allow remote connections. 通过这句话看看你的sqlserver是否允许远程连接。

(2)连接的字符串可以通过在vs中连接数据库,来copy字符串的,以免自己敲的时候出现错误。

(3)设置断点调试,看看vs的提示错误,仔细观察,各种方法都试试,一定能找到问题的答案的。    

------解决方案--------------------
重启数据库 端口改1433
------解决方案--------------------

其实开发一个项目,最好是统一工具,这样就会更安全。

关于设置开启远程:http://wenku.baidu.com/view/e7f921748e9951e79b892789.html

------解决方案--------------------
引用:
Quote: 引用:


其实开发一个项目,最好是统一工具,这样就会更安全。

关于设置开启远程:http://wenku.baidu.com/view/e7f921748e9951e79b892789.html