【发布时间】:2013-07-15 13:21:54
【问题描述】:
我的程序是“搜索员工” 在 Visual Studio 2008 中使用 VB Web 应用程序 我在 Microsoft Access 中使用数据库
我在我的电脑上对其进行编程,它可以 100% 工作。但是当我将项目移动到其他计算机以上传到服务器时,它有错误
ODBC--连接到“SQL ServerWDT02418\SQLEXPRESS”失败。
WDT02418 是我电脑的名称。但我在其他计算机上运行该项目。
我像这样使用数据库连接
Function CountEmpData(ByVal EN As String, ByVal Area As String, ByVal Product_type As String) As Integer
Dim CounterEmpData As Integer
Try
Dim ole As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\PROJECT_WD\e-OJT_Project6\Database\Employee.mdb")
ole.Open()
Dim sqlCommand As String = "SELECT COUNT(*) AS 'Counter' FROM Employee WHERE (Emp_ID LIKE '%" + EN + "%') AND (Area LIKE '%" + Area + "%') AND (Product_Type LIKE '%" + Product_type + "%')"
Dim myCommand As New OleDbCommand(sqlCommand, ole)
Dim myReader As OleDbDataReader = myCommand.ExecuteReader()
While myReader.Read()
CounterEmpData = myReader.GetInt32(0)
End While
myReader.Close()
ole.Close()
Catch ex As Exception
End Try
Return CounterEmpData
End Function
在线提示错误
Dim myReader As OleDbDataReader = myCommand.ExecuteReader()
有人请帮帮我!
【问题讨论】:
-
SQL Express 默认不支持来自另一台机器的连接。没关系,您可能不希望您的网站在您重新启动或关闭您的开发机器时死掉。解决方法很明显,将 dbase 也移动到该服务器。