Closed Thread
Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    10-19-2009
    Location
    india
    MS-Off Ver
    Excel 2003
    Posts
    27

    mysql with vba retive data

    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

  2. #2
    Forum Contributor
    Join Date
    09-22-2009
    Location
    Indianapolis, Indiana
    MS-Off Ver
    Office 2003 / Office 2007
    Posts
    114

    Re: mysql with vba retive data

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

    Code:
    Set rs = New ADODB.Recordset

  3. #3
    Registered User
    Join Date
    12-03-2009
    Location
    london
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: mysql with vba retive data

    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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0