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

[µo°Ý] ADO+Sql¦p¦ó¨Ï¥Îvba¨ç¼Æ(month)

[µo°Ý] ADO+Sql¦p¦ó¨Ï¥Îvba¨ç¼Æ(month)

§Úªºdatabase«Ø¥ß¦bworksheets("¸ê®Æ®w"),¦³Äæ¦ì"¤é´Á",¦ý¨S¦³Äæ¦ì"¤ë¥÷"
¥ÎADO+sql¬d¸ß ¸ê®Æ®w¸ê®Æ¤ë¥÷ªº°ß¤@­È:
"select distinct month(¤é´Á) from [¸ê®Æ®w$]"
"select distinct " & month & "(¤é´Á) from [¸ê®Æ®w$]"
¥H¤W2¥y³£¤£¦¨¥\,ÅãµM¬O month ¤£¯à¥Î©Î¤èªk¿ù
ª©¥D¯à¤£¯à±Ð§Ú¦p¦ó¼g,§Ú¥D­n¥Øªº·Qª¾¹D¸ê®Æ®w¨½¿é¤J¤F­þ´X­Ó¤ëªº¸ê®Æ,ÁÂÁÂ
lmh

¦^´_ 1# mhl9mhl9

"select distinct month([table].¤é´Á) from [table]"

TOP


test1¥i¥H§â¾ã­Ó¸ê®Æ®wcopy¨ìactivesheet.A1
test2´N¥X²{¤W­±ªº¿ù»~¹ï¸Ü®Ø
¤°麽¦a¤è¼g¿ù¤F?
Sub test1()
    ActiveSheet.Cells.ClearContents
    Set iR = Range("A1")
    iPath = ThisWorkbook.fullname
    iQ = "select * from [¸ê®Æ®w$]"  
   iSql
End Sub
Sub test2()
    ActiveSheet.Cells.ClearContents
    Set iR = Range("A1")
    iPath = ThisWorkbook.Path
    iQ = "select month(¸ê®Æ®w.¤é´Á) from [¸ê®Æ®w$]"
    iSql
End Sub
lmh

TOP

¥»©«³Ì«á¥Ñ mhl9mhl9 ©ó 2013-8-11 02:56 ½s¿è

¤£¦n·N«ä, test2¤¤, §Ú§âthisworkbook.fullname¥´¦¨hisworkbook.Path
©Ò¥H¥X¿ù
test5 ,¥i¥H¥¿±`¹B¦æ, §Ú¸ê®Æ®w¦³6­Ó¤ë¸ê®Æ,¦ýtest5¹B¦æµ²ªG«o¬O6­ÓJan

Sub test5()
    ActiveSheet.Cells.ClearContents
    Set iR = Range("A1")
    iPath = ThisWorkbook.FullName
    iQ = "select distinct  Month(¤é´Á) as ¤ë¥÷ from [¸ê®Æ®w$]"
    iSql
end sub
lmh

TOP

¬Ý¨Ó¬O®æ¦¡°ÝÃD,¸ê®Æ®w¦³6­Ó¤ë¸ê®Æ,distinct month(¤é´Á)¥X6­Ó"Jan"
distinct year(¤é´Á)¥X¤@­Ó"1905"
°ß¤@­Èªº­Ó¼Æ¬O¥¿½Tªº,¦ý­È¤£¹ï,«ç»ò°µ©O?
lmh

TOP

¦^´_ 2# HSIEN6001


    ¬Ý¨Ó¬O®æ¦¡°ÝÃD,¸ê®Æ®w¦³6­Ó¤ë¸ê®Æ,distinct month(¤é´Á)¥X6­Ó"Jan"
distinct year(¤é´Á)¥X¤@­Ó"1905"
°ß¤@­Èªº­Ó¼Æ¬O¥¿½Tªº,¦ý­È¤£¹ï,«ç»ò°µ©O?
lmh

TOP

¦^´_ 2# HSIEN6001

°ÝÃD¸Ñ¨M¤F,dictinct month(¤é´Á) from [¸ê®Æ®w$],µ²ªG¥X¤F6­Ó"Jan",¦ý§Ú§âµ²ªGÀx¦s®æªº®æ¦¡§ï¥Î"³q¥Î®æ¦¡",´NÅã¥Ü¥¿½Tªº1,2,3,4,5,6
¦n¤F,ÁÂÁ§A,§Ú¬O²Ä¤@¦¸¦bsql¨½¥Îvbaªºfunction,¬d¨ì¤£¬O³o»ò²³æ´N¥i¥H¥Î¤F,¦³ÂIºò±i,©Ò¥H¶Ã¤F®M.²³æªº®æ¦¡°ÝÃD¨S¦³·Q¨ì,ÁÂÁ§A¤F
lmh

TOP

¦^´_ 7# mhl9mhl9


¹ï¤£°_!²{¦b¤~¤W½u (*.*)
¬Q¤Ñ¸Õ¹L#2¨º¥yOK ,´N¬O#7ªºµª®×
©Ò¥Hµ¹±z¶K¤W°Ñ¦Ò
§¹¦¨´N¦n!!

TOP

¦^´_ 8# HSIEN6001

³o­Ó°ÝÃD·Ð¤F¦Û¤v´X¤Ñ,§A²Ä¤@¦¸µª§Ú«e,§ÚÃhºÃª½±µ¥Îmonth¨ç¼Æ,¦]¬°§AªºµªÂÐ,§Úı±o¥Îªk¦³¤H»{¦P,¦³ÂI«H¤ß¤F
­ì¨Ó§Ú³v­ÓÀˬd15­Ó¤À¤½¥q¥þ¦~¤é³øªí§¹¤£§¹¾ã,²{¦b¥i¥H¤@¦¸Àˬd§¹15­Ó¤½¥q¥þ¦~³øªí,®É¶¡§Ö¤£¤F¦h¤Ö,¦ýµ{¦¡¬yµ{¦n¹³µÎªA±o¦h.
¦hÁ¦hÁÂ
lmh

TOP

        ÀR«ä¦Û¦b : ½_ÁJµ²±o¶V¹¡º¡¡A¶V·|©¹¤U««¡A¤@­Ó¤H¶V¦³¦¨´N¡A´N­n¶V¦³Á¾¨Rªº¯ÝÃÌ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD