建立与SQL Server的连接时发生与网络相关或特定于实例的错误。 找到指定的服务器/实例时出错

将Web项目从测试环境移动到Web服务器,只要尝试打开与sql server的连接,就会发生此错误。

我们可以从sql server management studio插入和读取数据。

我们怀疑错误是从错误的连接字符串或使用集成安全性的sql server创建的,但是无法确认。

连接字符串。

   

它在哪里使用

 SqlConnection Connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DSVUShort"].ToString()); Connection.Open() // pops the error 

导致此错误是webConfig中的connectionString
在webConfig中设置connectionString。
webConfig中的connectionStrin名称和后面的代码必须相同。

在web.config中:

        

在代码中:

 SqlConnection Connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DSVUShort"].ToString()); Connection.Open(); 

在此处输入图像描述