Option Explicit
'定义ADO连接变量
Dim adoConn As ADODB.Connection
Dim adoRs As ADODB.Recordset
Private Sub Form_Load()
On Error Resume Next
Dim db_file As String
db_file = App.Path
If Right(db_file, 1) <> "\" Then db_file = db_file & "\"
db_file = db_file & "myLDF.mdb"
'打开数据库连接
Set adoConn = New ADODB.Connection
adoConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & db_file
adoRs.Close
End Sub
我用上面的代码连接myLDF.mdb数据库,以前正常打开,今天突然出错,当执行到“Set adoConn = New ADODB.Connection”时出现“自动化错误”,请大家帮忙看看,如何解决错误
从网上下载并安装mdac2.8mdactyp.exe
再在工程中引用ADO