使用VB6 & ADODB 开放存取2000 DB。连接字符串打开。我通过在打开记录集之前获取连接的 .STATE 来验证这一点。
Private Sub Form_Load()
With conn
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=C:\Path to database\MyDb.mdb;"
End With
conn.Open
Debug.Print conn.ConnectionString
End Sub
下面的代码片段显示了发生错误的行
Private Sub btnGO_Click()
Dim strDbName As String
Dim strg As String
Dim chkr As Variant
Dim MyCnt As Integer
chkr = False
Dim strsql As String
strsql = "Select * from [dbo].[BidItem]"
With rst
.ActiveConnection = conn
.Source = "Select * from [dbo].[BidItem]"
.Open -------------------------------------> Errors at this point
End With
With rst
If Not .EOF And Not .BOF Then
.MoveFirst
MyCnt = .RecordCount
End If
End With
MsgBox ("open")
MsgBox ("Count of TableRows: " & MyCnt)
Set rst = Nothing
End Sub
编辑:确切的错误信息是Run-Time Error '-2147467259 (80004005)': Could not find file 'C:\Program Files (x86)\Microsoft Visual\VB98\dbo.mdb'