SUB Test()
On Error GoTo aaa
Dim ErrorCode As Long
Dim cnnA As New ADODB.Connection
Dim rsA As New ADODB.Recordset
Dim cnnAStr, StrAccess As String
cnnAStr = "rovider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Test1.mdb"
cnnA.Open cnnAStr
Dim cnnS As New ADODB.Connection
Dim rsS As New ADODB.Recordset
Dim cnnSStr, StrSql As String
cnnSStr = "rovider=SQLOLEDB;Data Source=123.45.54.321;Database=Test2;User ID=saassword=123"
cnnS.Open cnnSStr
StrAccess = "select * from aaa"
rsA.Open StrAccess, cnnA, adOpenStatic, adLockOptimistic
If ErrorCode = 0 Then
rsA.Close
Set rsA = Nothing
'表已存在!","
cnnA.Execute ("Drop Table aaa")
End If
StrSql = "select * into aaa from [" & cnnSStr & "].aaa"
Set rsA = cnnA.Execute(StrSql)
rsA.Close
Set rsA = Nothing
MsgBox "ok!"
Exit Sub
aaa:
ErrorCode = Err.Number
Resume Next
End Sub
执行到红色一行,报错:-2147467259 找不到可安装的 ISAM。
检查注册表没法现问题。两个数据库连接正常。
感觉问题出在 StrSql = "select * into aaa from [" & cnnSStr & "].aaa"
请高手帮忙!