我的節目是「搜索僱員」使用VB web應用程序,我使用的數據庫在Microsoft Access如何解決「ODBC連接失敗」在Visual Studio 2008
我編程,它在我的電腦工作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移動到該服務器。 –