Dim catDB As ADOX.Catalog
Dim tblLink As ADOX.Table
Set catDB = New ADOX.Catalog
Dim cn As New ADODB.Connection
cn.Open "rovider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & App.Path & "\newtest.mdb"
'Link the Orders_Table in the Workbook to the Access Northwind Database.
'The name of the linked, or attached table, in NorthWind will be "LinkedXLS"
' catDB.ActiveConnection = "rovider=Microsoft.Jet.OLEDB.4.0;" & _
' "Data Source=" & App.Path & "\newtest.mdb"
Set catDB.ActiveConnection = cn
Set tblLink = New ADOX.Table
With tblLink
.Name = "rocPipeTbl000"
Set .ParentCatalog = catDB
.Properties("Jet OLEDB:Create Link") = True
.Properties("Jet OLEDBink Provider String") = _
"ODBC;DRIVER={MySQL ODBC 5.1 Driver};SERVER=localhost;DATABASE=PubSpec;UID=XXXX;PWD=XXXX;OPTION=3;charset=gbk"
.Properties("Jet OLEDB:Remote Table Name") = "procpipetbl"
End With
' On Error Resume Next
catDB.Tables.Append tblLink '<---代码至此失败,产生错误“ODBC--调用失败"
' Set cn = catDB.ActiveConnection
cn.Execute "Select * into ProcPipeTbl from ProcPipeTbl000"
Set tblLink = Nothing
cn.Close
Set catDB = Nothing