我之前使用的一段代码遇到了一些问题,并且已经在其他项目上工作,而不是我现在的项目。
Dim strdbPass As String = "pass"
Dim connString As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=\\EPOS\bin\Debug\EPoSDb.aacdb;Jet OLEDB:Database Password=" & strdbPass & ";"
Dim strSearch As String
Dim MyConn As OleDbConnection
Dim da As OleDbDataAdapter
Dim ds As DataSet
Dim tables As DataTableCollection
Dim source1 As New BindingSource
Dim dr As OleDbDataReader
Dim booFailLog As Boolean = False
Sub procFindStaffDB(ByVal strClerkID As String, ByRef booUserNotExists As Boolean)
Dim strClerk As String = ""
Dim strForename As String = ""
Dim strSurname As String = ""
Dim strShortName As String = ""
Dim strLevel As String = ""
Dim strClocked As String = ""
MyConn = New OleDbConnection
MyConn.ConnectionString = connString
MyConn.Open()
strSearch = "SELECT * FROM Staff WHERE ([ClerkID] = '" & strClerkID & "')"
Dim cmd1 As OleDbCommand = New OleDbCommand(strSearch, MyConn)
dr = cmd1.ExecuteReader
While dr.Read()
strClerk = dr("ClerkID").ToString
strForename = dr("Forename").ToString
strSurname = dr("Surname").ToString
strShortName = dr("Short Name").ToString
strLevel = dr("Level").ToString
strClocked = dr("Clocked").ToString
End While
MyConn.Close()
If strClerkID <> strClerk Then
booUserNotExists = True
Else
booUserNotExists = False
End If
End Sub
将断点添加到Myconn.open()
以及之后的几行,但在打开连接后它会跳出程序。
答案 0 :(得分:0)
文件扩展名中有拼写错误:
2013-01-26 00:00:00.000
应该是
...EPoSDb.aacdb;Jet OLEDB...