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

[¤À¨É] ¨Ï¥ÎADO¬d¸ßDataBase

[¤À¨É] ¨Ï¥ÎADO¬d¸ßDataBase

¥»©«³Ì«á¥Ñ Min ©ó 2010-6-29 22:20 ½s¿è

»Ý¤Þ¥Î Microsoft ActiveX Data Objects 2.5 Library ¤Î¥H¤Wª©¥»
  1. Sub ADO_QueryTable()
  2.     Dim Cnnl As New ADODB.Connection
  3.     Dim Rst As New ADODB.Recordset
  4.     Dim SQL As String
  5.     Dim lCol As Long
  6.     Dim lRow As Long
  7.    
  8.     Cnnl.Open "Driver={MySQL ODBC 3.51 Driver};Server=TEST;Port=3306;Database=TEST;CharSet=big5;Uid=TEST;Pwd=TEST;Option=16387"  '³s±µSystem

  9.     SQL = "SELECT COL0,COL1,COL2,COL3,COL4,COL5 FROM TABLE"
  10.     Rst.Open SQL, Cnnl, adOpenKeyset, adLockOptimistic
  11.     Do Until Rst.EOF
  12.         For lCol = 0 To Rst.Fields.Count - 1
  13.             Cells(lRow, lCol + 1).Value = Rst(lCol)
  14.         Next
  15.         lRow = lRow + 1
  16.         Rst.MoveNext
  17.     Loop
  18.    
  19.     Set Cnnl = Nothing
  20.     Set Rst = Nothing
  21. End Sub
½Æ»s¥N½X
­Y¬O§Ú¦^µª¡A¨Ï±zº¡·N¡A½Ð±zÅý§Úª¾¹D¡I                  
­Y¬O§Úªº¦^ÂСA±z¤´¦³¨ä¥L¨£¸Ñ¡A¤]½Ð±z¤£¶Þ«ü±Ð¡I

        ÀR«ä¦Û¦b : ¤@­Ó¤Hªº§Ö¼Ö¡D¤£¬O¦]¬°¥L¾Ö¦³±o¦h¡A¦Ó¬O¦]¬°¥L­p¸û±o¤Ö¡C
ªð¦^¦Cªí ¤W¤@¥DÃD