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

«ç»òŪ¨úrecordsetªº¦UÄæ¦ìªº­È

«ç»òŪ¨úrecordsetªº¦UÄæ¦ìªº­È

Dim cn
        DbName="DB.accdb"
    sql_command="select  *  from baseinfo"
    Set cn = CreateObject("adodb.connection")
    cn.Open "Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=" & ThisWorkbook.Path & "\" & DbName
    Set rs = cn.Execute(sql_command)
    sheets"(sheet1").cells(1,1)=rs.fields(0).vale
    cn.Close



  sheets"(sheet1").cells(1,1)=rs.fields(0).vale <----------³o¸Ì¦³°ÝÃD
¦bVBA¸Ì­n«ç»òªí¥Ü©O???
woteil

¦^´_ 1# woteil


    sheets"(sheet1").cells(1,1)=rs.fields(0).vale <----------³o¸Ì¦³°ÝÃD

   ¬O¦]¬°¥´¿ù¦rªºÃö«Y¶Ü¡Hvalue¡H

TOP

¦^´_ 2# owen06


    ¤£¦n·N«ä..¬O¥´¿ù..¦ý½T¹ê¦³°ÝÃD
2013³D¦~¥þ¶Ô¼ú³¹

[¹ïwoteil¨Ï¥Îª¯¥J¥d]
       
1# ¸õÂà¨ì » ­Ë§Ç¬Ý©«
¥´¦L
¦rÅé¤j¤p: tT
µoªí©ó ¥b¤p®É«e | ¥u¬Ý¸Ó§@ªÌ
«ç»òŪ¨úrecordsetªº¦UÄæ¦ìªº­È
Dim cn
        DbName="DB.accdb"
    sql_command="select  *  from baseinfo"
    Set cn = CreateObject("adodb.connection")
    cn.Open "Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=" & ThisWorkbook.Path & "\" & DbName
    Set rs = cn.Execute(sql_command)
    sheets"(sheet1").cells(1,1)=rs.fields(0).value
    cn.Close



  sheets"(sheet1").cells(1,1)=rs.fields(0).value <----------³o¸Ì¦³°ÝÃD
¦bVBA¸Ì­n«ç»òªí¥Ü©O???
woteil

TOP

¦^´_ 1# woteil


    Dim cn
        DbName="DB.accdb"
    sql_command="select  *  from baseinfo"
    Set cn = CreateObject("adodb.connection")
    cn.Open "Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=" & ThisWorkbook.Path & "\" & DbName
    Set rs = cn.Execute(sql_command)
    'sheets"(sheet1").cells(1,1)=rs.fields(0).value
    sheets"(sheet1").cells(1,1).CopyFromRecordset (rs)
    cn.Close

§ä¨ì¤@­Ó¤èªk..¥i¥H³o»ò°µ
sheets"(sheet1").cells(1,1).CopyFromRecordset (rs)

¦ýÁÙ¬OµLªk¥u¨ú¬Y­ÓÄ檺­È
woteil

TOP

§Ú¦Û¤v¥H«e³o¼Ë¼g¡A§A°Ñ¦Ò¬Ý¬Ý
  1.         sub ex
  2.                
  3.                         Set cnn = CreateObject("adodb.connection")
  4.                         cnn.Open ("Driver={SQLite3 ODBC Driver};database=" & ThisWorkbook.Path & "\CB.sqlite")'¦Û¦æ­×§ïdrive
  5.                         Set rss = cnn.Execute("select * from XXX")
  6.                                 For i = 0 To rss.Fields.Count - 1 '¨ú¼ÐÃD¡A¦pªG¤£­n¥i¬Ù²¤
  7.                                         Cells(1, i + 1) = rss.Fields(i).Name
  8.                                 Next
  9.                         Worksheets("X").Cells(2, 1).CopyFromRecordset (rss) 'cells(2,1)²Ä¤@¦æ¦³¼ÐÃD
  10.                         cnn.Close

  11.                         Set cnn = Nothing
  12.                         Set rss = Nothing
  13.                
  14.                 end sub
½Æ»s¥N½X
¦^´_ 4# woteil

TOP

        ÀR«ä¦Û¦b : ¡i®É¤é²öªÅ¹L¡j¤@­Ó¤H¦b¥@¶¡°µ¤F¦h¤Ö¨Æ¡A´Nµ¥©ó¹Ø©R¦³¦hªø¡C¦]¦¹¥²¶·»P®É¶¡Ävª§¡A¤Á²ö¨Ï®É¤éªÅ¹L¡C
ªð¦^¦Cªí ¤W¤@¥DÃD