Problem with establish connection with MySQL DB by VBA

Gadziu

New Member
Joined
Aug 23, 2014
Messages
7
Hi,
I've done everything what is written in Internet, but still I get error. But from begining. I want to connect with MySQL DB from VBA level. I've installed ODBC connector and have made user DNS in it and have procced test, which complete successful. In Ms Visual Basic in Tools->References-> I checked Microsoft Activex Object 2.8.
My ODBC settings
1.png

2.png


By now my code looks like this
Code:
Dim oConn As ADODB.Connection

Private Sub ConnectDB()

    Set oConn = New ADODB.Connection

    oConn.Open "DRIVER={MySQL ODBC 5.1 Driver};" & _
    "SERVER=sql.serwer;" & _
    "DATABASE=mydatabase;" & _
    "USER=muusername;" & _
    "PASSWORD=mypassword;" & _
    "Option=3"
End Sub

This is the error
3.png


Any ideas?
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
This is string... For example I could write "localhost". I think it irrelevant what is there written in case of this problem
 
Upvote 0
Have you tried recording a macro while performing your query manually? That should give you some starter VBA code.
 
Upvote 0

Forum statistics

Threads
1,216,361
Messages
6,130,180
Members
449,563
Latest member
Suz0718

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top