开发者

SQL Error : error: 40 - Could not open a connection to SQL Server

开发者 https://www.devze.com 2022-12-19 17:29 出处:网络
I Get this error message whenever I tried to up my aspx page. An error has occurred while establishing a connection to the server.When connecting to SQL Server 2005, this failure may be caused by the

I Get this error message whenever I tried to up my aspx page.

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote co开发者_开发技巧nnections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

whic is connected in this connection string

SqlConnection conn = new SqlConnection("Data Source=192.168.xxx.xxx;Initial Catalog=DBSample;User ID=dev;Password=pass;Integrated Security=SSPI;"))

The weird thing is that the server that I'm connecting has already hosting some aspx page. I don't knnow if there's missing in my connectiong string Thanks. and I know the server that I'm connecting to is already allowed remote connection since it's already hosted some aspx websites. :(

Thanks!


Do you need to add an instance name to your connection string? Do you have the SQLBrowser service running on the target machine, or do you have to specify a port for the instance?

You also get that very same error when the database doesn't exist at the location that you are trying to connect to. Have tried looking at the connection strings of the aspx pages that are successfully connecting?

edited: Specifying Integrated Security=SSPI means you will be using Windows authentication to login to the database. What user is your aspx page running as (check your app pool)? Does it have the rights to log in to the database? This could also explain why it works on one server but not another.


Are you trying to connect to a hosted SQL Server over TCP/IP?

The reason I ask is some firewalls block traffic over Port 1433.

If not then it is simply a case of validating the connection string details and ensuring the SQL Server Engine is actually running...

Have you EVER been able to connect to this database from the PC you are currently attempting this connection on?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号