VBA Run-time error '-2147467259 (80004005)

2019-08-12 06:55发布

I am trying to connect to mysql using Excel VBA, I am using Excel 2013. I am new to VB, so i followed this example: Inserting Data Into MySQL From Excel Using VBA

Here is my connection code:

Private Sub ConnectDB()
Set oConn = New ADODB.Connection
oConn.Open "DRIVER={MySQL ODBC 5.1.13 Driver};" & _
    "SERVER=123.456.0.188;" & _
    "DATABASE=MyDB;" & _
    "USER=MyUser;" & _
    "PASSWORD=MyPassword;" & _
    "Option=3"
End Sub  

When I try to execute this code, I get the following error:

---------------------------
Microsoft Visual Basic for Applications
---------------------------
Run-time error '-2147467259 (80004005)':

Automation error
Unspecified error  

Here are my references:

VBA References

I know this question may look like a duplicate but I have looked through most of questions similar to this one, they do not solve my issue.

1条回答
Deceive 欺骗
2楼-- · 2019-08-12 07:21

The ODBC drivers must match the 32 or 64Bit architekture of the VBA application.

Otherwise VBA isn't able to use the odbc drivers.

查看更多
登录 后发表回答