VBA with MysQL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • murugavelmsc
    New Member
    • Apr 2008
    • 54

    VBA with MysQL

    Hi,

    i develop a application with VB and mysql.

    my question: in excel a1 column have a 10 values. Based on the values we get data from mysql and place it in a2 columns (corresponding row)

    Eg:

    Excel

    A1 Column A2 columns
    5 retrieve the value from database based upon 5
    6 retrieve the value from database based upon 6
    7 retrieve the value from database based upon 7
    8 retrieve the value from database based upon 8

    i try the below mentioned code
    conn.Connection String = "DRIVER={My SQL ODBC 3.51 Driver};" & _
    "SERVER=172.16. 1.20;" & _
    "DATABASE=p mg;" & _
    "UID=pmgusr;PAS SWORD=pmgusr;OP TION=3"

    With Worksheet
    Dim i As Integer
    i = 0

    For rowcursor = i To 100
    sSQL = "SELECT activity_code from activitydetails where combine=cells(r owcursor, i);"
    Next

    End With

    conn.Open

    Set dbRecset = New ADODB.Recordset

    dbRecset.Cursor Location = adUseClient
    dbRecset.Open Source:=sSQL, ActiveConnectio n:=conn, CursorType:=adO penForwardOnly, _
    LockType:=adLoc kReadOnly, Options:=adCmdT ext
    dbRecset.MoveFi rst
    For l = 1 To dbRecset.Fields .Count

    Worksheets(1).C ells(1, l).Value = dbRecset.Fields (l - l).Name

    Next l


    For l2 = 1 To dbRecset.Record Count

    For l = 1 To dbRecset.Fields .Count

    Worksheets(1).C ells(l2 + 1, l).Value = dbRecset.Fields (l - 1).Value

    Next l

    dbRecset.MoveNe xt

    Next l2

    please guide me

    thanks
    murugavel
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    are you facing any problem or getting any error with your code ?

    Comment

    • murugavelmsc
      New Member
      • Apr 2008
      • 54

      #3
      Originally posted by debasisdas
      are you facing any problem or getting any error with your code ?
      ya i got a error of unknow columns rowcursor

      Comment

      Working...