¤@¡B·í¨ú±oSQLªº¸ê®Æ«á(¤w¸g±o¨ì¸ê®Æ),¥Îþ¤@ºØ»yªk,¯à°÷³Ì§Ö³tªº±N¸ê®Æ¿é¥X¦Üexcel
EX:rng°}¦C¿é¤Jªº¤è¦¡,¦]¸Ó¬O:range("a1").resize(ubound(rng),ubound(rng,2)).value=rng
¥i¬OSQL¨ú±o¸ê®Æ«áµLªk¨Ï¥Î¦¹»yªk,¤£¾å±o°ª¤â¤j¤j̳£¬O¥Îþ¤@ºØ»yªk
¤p§Ì¥uÀ´±o¤U¦C2ºØ»yªk,½Ð°Ý¦³§ó§Ö³tªº¿é¥X»yªk¶Ü?©Î¬O±qþÃä¥i¥H±oª¾¬ÛÃöªº»¡©úºô¯¸
conn¬°ADODB.Connection
1
ActiveSheet.Range("a1").CopyFromRecordset conn.Execute(strSQL)
2
Rng = conn.Execute(strSQL).GetRows 'Âର°}¦C(¬Û¤Ïªº)
Range("a1").Resize(UBound(Rng, 2) + 1, UBound(Rng) + 1).Value = Application.Transpose(Rng)
¤G¡B·í¨ú±oSQLªº¸ê®Æ«á(¤w¸g±o¨ì¸ê®Æ),¥Îþ¤@ºØ»yªk,¯à°÷³Ì§Ö³tªº±N¸ê®ÆÂà´«¬°°}¦C
¤p§Ì¥u·|¥Îgetrowsªº¤èªkÂà´«¬°°}¦C(¦ýÁÙ»ÝnÂà¸m¡A¤~¬O¥¿±`ªº¶¶§Ç)
©Î¬O¤£¥ÎÂà´«¬°°}¦C,n¦p¦óŪ¨ú¥X¦¹È(¦b¤£¿é¥X¦ÜexcelÀx¦s®æ¤Wªº±¡ªp¤§¤U¡A¦]¬°¿é¥X¤§«á¦AŪ¨ú¹ê¦b¤ÓºC¦Ó¥B¤£«K) |