#  Other Applications & Softwares  > Access Tables & Databases >  >  mysql with vba retive data

## naga_raaju

hi

i am connecting to mysql database using VBA.

i am new to VBA  i tried like this 

Dim oConn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim rsc As ADODB.Recordset
Dim strsql as String 

 Set oConn = New ADODB.Connection
    oConn.Open "DRIVER={MySQL ODBC 5.1 Driver};" & _
    "SERVER=localhost;" & _
    "DATABASE=tamp;" & _
    "USER=root;" & _
    "PASSWORD=test;" & _
    "Option=3"
 strsql = "SELECT * from info"
 rs.Open strsql, oConn, adOpenStatic, adLockOptimistic

 i got error upto this code

 my intention is to display the info table data .

please guide me how to retrieve the data from info table.

any one guide me

----------


## Marzuk

Looks like you are probably getting an error because rs is not created.  Add this prior to using rs.




```
Please Login or Register  to view this content.
```

----------


## edon

One thing is to make sure you actually have the odbc driver installed.  There's a great video tutorial that takes you through the steps of downloading and installing the driver as well as pulling info from a mysql db.  I would check it out because maybe you need to create a new .dsn file as well and also maybe a macro is not the best route to take.

http://www.youtube.com/watch?v=SxHQuK17MN4

HTH  :Smilie:

----------

