ªð¦^¦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 : ¡i¥Í©R¦b©I§l¶¡¡j¦òªû»¡¡G¡u¥Í©R¦b©I§l¶¡¡C¡v¤HµLªkºÞ¦í¦Û¤vªº¥Í©R¡A§óµLªk¾×¦í¦º´Á¡AÅý¦Û¤v¥Ã¦í¤H¶¡¡C¬JµM¥Í©R¥h¨Ó³o»òµL±`¡A§Ú­Ì§óÀ³¸Ó¦n¦n¦a·R±¤¥¦¡B§Q¥Î¥¦¡B¥R¹ê¥¦¡AÅý³oµL±`¡BÄ_¶Qªº¥Í©R¡A´²µo¥¦¯uµ½¬üªº¥ú½÷¡A¬M·Ó¥X¥Í©R¯u¥¿ªº»ù­È¡C
ªð¦^¦Cªí ¤W¤@¥DÃD