How to import data from Excel to MYSQL Server using VB

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kelvenng
    New Member
    • Jul 2007
    • 1

    #1

    How to import data from Excel to MYSQL Server using VB

    Hi all hope some one can help me solve my problem.
    Actually I want import data from excel to my MYSQL server by using VB6
    I facing the problem on my coding and system show me the error.
    below is my VB coding hope some one can tell me my error.
    Thanks

    Dim cn As ADODB.Connectio n
    Dim sql As String
    Dim lngrecsaff As Long

    Set cn = New ADODB.Connectio n
    cn.Open "DRIVER={My SQL ODBC 3.51 Driver};DSN=''; DATABASE=" & DBName & ";SERVER=" & Server & ";UID=root;PASS WORD='password' ;PORT=3306;OPTI ON=3;STMT=;"

    sql = "select * into z from " & _
    "database('micr osoft.jet.oledb .4.0'," & _
    "'excel 8.0;database=C: \insert test\mak.xls', " & _
    "'select * from [sheet1$]')"
    Debug.Print sql
    cn.Execute sql, ingrecsaff, adExecuteNoReco rds
    'strsql, lngrecsaff, adexcutenorecor ds
    Debug.Print "records affected: " & ingrecsaff

    cn.Close
    Set cn = Nothing
Working...