ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] ±NExcel·í¤¤ªº¸ê®ÆÂà¤J¸ê®Æ®w¤¤·|¥X²{¨Ï¥ÎªÌ¦Û­q«¬ºA©|¥¼©w¸q

[µo°Ý] ±NExcel·í¤¤ªº¸ê®ÆÂà¤J¸ê®Æ®w¤¤·|¥X²{¨Ï¥ÎªÌ¦Û­q«¬ºA©|¥¼©w¸q

½Ð°Ý³o­Ó¤Ö¤F¤°»ò?

Sub Export2Mysql()
'±NExcel·í¤¤ªº¸ê®ÆÂà¤J¸ê®Æ®w¤¤
    Dim conn As ADODB.Connection
    Dim rs As ADODB.Recordset
    Dim fld As ADODB.Field
    Dim sql As String
    Set conn = New ADODB.Connection
    '³o¸Ì­n´«¦¨§Aªº¦øªA¾¹ ®w¦W ¥Î¤á¦W ±K½X
    conn.ConnectionString = "DRIVER={MySQL ODBC 5.1 Driver};" & "SERVER=xxx.xxx.xxx.xxx;" & " DATABASE=test;" & "UID=test WD=password; OPTION=3"
    conn.Open
    '·Ç³Æ³Ð«Øªí
    conn.Execute "drop table if exists test"
    'ª`·N³o¸Ìªº¦U¦CÃþ«¬³]©w
    conn.Execute "create table test(name text,pass text)"
    '«ö¦æ¾É¤J,³o¸Ì°²³]²Ä¤@¦C¦sªº¬Oname¡A²Ä¤G¦C¦sªº¬Opass
    For i = 1 To 20
        conn.Execute "insert into test(name,pass) values('" & Cells(i, 1).Text & "','" & Cells(i, 2) & "')"
    Next i
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseServer
    '¨Ï¥Î¤U­±ªº¥N½XÅçÃÒ
    rs.Open "select * from test", conn
    rs.MoveFirst
    Do Until rs.EOF
        For Each fld In rs.Fields
            Debug.Print fld.Value,
        Next
        rs.MoveNext
        Debug.Print
    Loop
    rs.Close
    conn.Close
End Sub
XX

¥»©«³Ì«á¥Ñ kimbal ©ó 2011-10-23 13:24 ½s¿è

¤w¸g³]¦n¤FADO¤Þ¥Î?
¦bVBE: ¤u¨ã->³]©w¤Þ¥Î¶µ¥Ø
¥´¤ÄADO 2.8


ÁÙ¦³MYSQLªºODBC¦³¨S¦³¸Ë¦n?
À´±oµo°Ý,µª®×´N·|¦b¨ä¤¤

¤µ¤éの¤@¬íは  ©ú¤éにない
http://kimbalko-chi.blogspot.com
http://kimbalko.blogspot.com

TOP

¦^´_ 2# kimbal

¤u¨ã->³]©w¤Þ¥Î¶µ¥Ø
¥´¤ÄADO 2.8
¦]¬°¤@ª½¦b¸Õ¡A¨S¦³¦sÀÉ¡A­èµo²{¨S¦³¤Ä¨ì
¨º¥H¸g³]¦n¤F¡A·|¥X²{¦p¹ÏÀɤ@¼Ëªº¿ù»~°T®§

§ÚªºOS¬OWIN 7 64Bit englishª©¥»
§Ú¨Ï¥ÎvmwareµêÀÀ¥X¤@­Óxp¨t²Î
ODBC´ú¸ÕOK

¦ý¨Ï¥Îºô¸ô¤W©Ò§äªºVBA»yªk§@´ú¸Õ¡AµLªk¥¿±`°õ¦æ¡C

Untitled.jpg (187.36 KB)

Untitled.jpg

XX

TOP

¥»©«³Ì«á¥Ñ kkkajw ©ó 2011-10-23 17:35 ½s¿è

­è¸Õ¤F¤@¤U¡A¦n¹³¨Sªk¥¿±`±N¤u¨ã->³]©w¤Þ¥Î¶µ¥Ø
¥´¤ÄADO 2.8¡A¦sÀÉ¡A¥u­n­«·s¶}±ÒEXECL´N·|Åܦ¨¨S¥´¤Ä
¤]¦³¸ÕµÛ±NEXECL¦sÀɦA¥h¶}±Ò¡A¬O¦]¬°§Ú¥ÎWindows7 64bitªºÃö«Y¶Ü?

§Ú¥ý¦bwin xp¦w¸Ëoffice 2007¡A´ú¸Õ§¹¤]¬OADO 2.8¨º­Ó¿ï¶µÁÙ¬O·|³Q®³±¼¡A©Ç©Çªº¡C
XX

TOP

        ÀR«ä¦Û¦b : ±o²z­nÄǤH¡A²zª½­n®ð©M¡C
ªð¦^¦Cªí ¤W¤@¥DÃD