当前位置:编程学习 > C#/ASP.NET >>

关于ASP.NET连接SQL2005的web.config配置问题,急,在线等

    本人做了一个网站,在本地连结供应商给的服务器没有问题,但把程序传到数据器上就报,有没有哪位兄弟遇到过这个错误(错误如下):
  Server Error in '/' Application.
  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: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.) 

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Data.SqlClient.SqlException: 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: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)

Source Error: 

Line 165:            //----------------返回一个SqlDataReader对像------------------------------
Line 166:            SqlConnection con = new SqlConnection(connectionString);
Line 167:             con.Open();
Line 168:               SqlCommand com = new SqlCommand(strSql,con);
Line 169:                SqlDataReader sdr = com.ExecuteReader();
 
备注:
   SOURCE ERROR报错是在CON。OPNE()是报错,应该是连结数据库时有问题,但我在我的电脑上连结供应商给的数据库连结信息是没有任何问题的,网站一切正常,只是把程序上传到空间方就出现这个问题。
  --------------------编程问答-------------------- 已经好几天了,各位兄弟在我看看啊,分不够的在加啊 --------------------编程问答-------------------- 连接字符串有问题。。。。或者你服务器远程连接没有打开。。

连接不到服务器 --------------------编程问答-------------------- sql server外围应用配置器->服务和连接的外围应用配置器->打开MSSQLSERVER节点下的Database Engine 节点,先择"远程连接",接下建议选择"同时使用TCP/IP和named pipes",确定后,重启数据库服务
--------------------编程问答-------------------- 回复 porschev:
    如果说是空间方服务器的远程连结没有找开,可是我从我的电脑上是可以连结空间方的服务器的,程序没有任何问题


to wuyq11:
   你说的几部我已经设置过了,我在本地的程序是可以连结空间方提供的数据库的,现在的问题是传到空间上就报上面的错误
--------------------编程问答-------------------- --------------------编程问答-------------------- TCP/IP里。。右键。。。IP选项卡中。。把自己机器对应的IP启用一下试试。。 --------------------编程问答-------------------- porschev:
    TCP/IP,这个在哪里?在空间方哪边的吗? --------------------编程问答-------------------- 打印出
connectionString
看看什么格式的 --------------------编程问答--------------------
引用 7 楼 binhuodao 的回复:
porschev:
  TCP/IP,这个在哪里?在空间方哪边的吗?


sql server外围应用配置器->服务和连接的外围应用配置器->打开MSSQLSERVER节点 --------------------编程问答-------------------- to porschev:
sql server外围应用配置器->服务和连接的外围应用配置器->打开MSSQLSERVER节点,这里面没有找到TCP/IP,而且里面的节点都没有右键的 --------------------编程问答-------------------- /upload/20131225/C51S1VTZ4UIEN6SW.png
--------------------编程问答-------------------- 连接字符串主机和实例之间应该是反斜杠“\” --------------------编程问答-------------------- 连接不到数据库,看你的数据库连接字符串是怎么写的 --------------------编程问答-------------------- axaxa
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,