【发布时间】:2016-09-22 21:46:15
【问题描述】:
它可以在我的笔记本电脑上使用,但是当我将它上传到服务器上时它不起作用并这样说:
The network path was not found
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.ComponentModel.Win32Exception: The network path was not found
Source Error:
Line 58: using (SqlCommand cmd1 = new SqlCommand("Select word_text from words where word_id = 1", con))
Line 59: {
Line 60: con.Open(); "That show in red"
Line 61: SqlDataReader dr = cmd1.ExecuteReader();
Line 62: if (dr.Read())
这是我来自服务器的连接字符串:
Connection string: workstation id=textdatabase.mssql.somee.com;packet size=4096;user id=Naeemh_SQLLogin_1;pwd=t7xtp3wlad;data source=textdatabase.mssql.somee.com;persist security info=False;initial catalog=textdatabase
我的笔记本电脑中的连接:
Connection string:Data Source=Q-PC;Initial Catalog=Text;IntegratedSecurity=True
【问题讨论】:
-
可能是数据库连接不正确。
-
我确信这是正确的。
-
它写 con.Open();当我从服务器打开时显示为红色
-
该错误与它告诉您错误是什么的数据库无关..您的
.aspx page or code behind中有硬编码路径吗?您需要显示相关的代码您怎么知道这是导致错误的行,它可能是在点击此行之前上面的代码..编辑问题并显示所有相关代码..还添加一些日志记录,以便您确切知道它在哪里抛出错误..在哪里跟踪日志..?然后再次向我们展示实际的连接字符串,因为您本地的路径在远程服务器上永远不会相同..
标签: c# sql asp.net database sql-server-2008-r2