连接到服务器上的数据库时发生连接错误 [英] Connection error whie connection to databse on server

查看:124
本文介绍了连接到服务器上的数据库时发生连接错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

尝试打开我的网站时出现此错误.它可以在本地主机上运行时工作正常,但是当我尝试在线打开它时却出现错误.
我尝试用Google搜索它,但找不到满意的答案.


建立与SQL Server的连接时发生与网络相关或特定于实例的错误.服务器未找到或无法访问.验证实例名称正确,并且已将SQL Server配置为允许远程连接. (提供者:命名管道提供者,错误:40-无法打开与SQL Server的连接)

这是我在web.config
中的连接字符串

Hi all!!

i am getting this error when i am trying to open my website . it''s working fine when it is made to run on local host but gives me error when i try to open it online.
I tried to google it but coudn''t find a satisfactoty ans.


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)

this is my connection string in web.config

<add name="Connstr" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ndo.mdf; uid=myid; pwd=mypwd" providerName="System.Data.SqlClient" 

推荐答案



只需将数据源作为即可.然后重试.

并检查用户ID和密码是否正确...
Hi,

Simply put datasource as . and try again.

And check whethere user id and password are correct ...


基本上,当您无法连接到SQL Server时,问题可能是:
1)网络问题,
2)SQL Server配置问题.
3)防火墙问题,
4)客户端驱动程序问题,
5)应用程序配置问题.
6)身份验证和登录问题.

Basically, when you failed to connect to your SQL Server, the issue could be:
1) Network issue,
2) SQL Server configuration issue.
3) Firewall issue,
4) Client driver issue,
5) Application configuration issue.
6) Authentication and logon issue.

检查这些
解决SQL连接问题的步骤 [ ^ ]
SQL Server 2005连接性问题疑难解答-第一部分 [对SQL Server 2005中的连接问题进行故障排除-第二部分 [ ^ ]
对SQL Server 2005中的连接问题进行故障排除-第III部分 [ ^ ]

顺便说一句,还要检查这堆中是否有将来的错误

Check these
Steps to troubleshoot SQL connectivity issues[^]
SQL Server 2005 Connectivity Issue Troubleshoot - Part I[^]
Troubleshoot Connectivity Issue in SQL Server 2005 - Part II[^]
Troubleshoot Connectivity Issue in SQL Server 2005 - Part III[^]

BTW check this bunch also for future errors


<add name="Connection" connectionstring="Data Source=ipaddress;Initial Catalog=databasename;Persist Security Info=true; User Id=sa;Password=password;">
   providerName="System.Data.SqlClient" />
</add>


这篇关于连接到服务器上的数据库时发生连接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆