- ©«¤l
- 361
- ¥DÃD
- 57
- ºëµØ
- 0
- ¿n¤À
- 426
- ÂI¦W
- 0
- §@·~¨t²Î
- win7
- ³nÅ骩¥»
- 2003,2010
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2010-5-13
- ³Ì«áµn¿ý
- 2022-12-8
|
§ä¨ì¸Ñ¨Mªº¤èªk¤@¡A«D¥¿¦¡¡K
sql»y¥y¨Ò¦p
INSERT INTO "ªí®æ¦W" ("Äæ¦ì1", "Äæ¦ì2", ...)VALUES ("È1", "È2", ...);
sqlite¥¦¤¹³\
INSERT INTO "ªí®æ¦W" ("Äæ¦ì1", "Äæ¦ì2", ...)VALUES ("È1", "È2", ...),("È3", "È4", ...),("È5", "È6", ...);
ªº¤èªk¡A¤@¦¸³Ì¦h¿é¤J500²Õ¼ÆÈ¡A¶W¹L«á¤@¼Ë·|³ø¿ù
¦pªG§A¦³1534²Õninsert¶i¸ê®Æ®w¤¤¡A¥i¥H¤À¦¨¥|²Õ 34 500 500 500 ªº¤èªk¤À§å¥[¶i¸ê®Æ®w¤¤
¦pªG¬O¤@²Õ²Õ¿é¤J¡A¤W¨Ò¤j·§n30¬í¥H¤W
¦pªG¬O¤À¥|²Õ¿é¤J¡A¦ô¤£¥Î2¬í
¥H¤U¬OÓ¤Hµ{¦¡½X¡G¶È¨Ñ°Ñ¦Ò- Sub sqlite§å¦¸insert¦hµ§¦¨¥\()
- '³Ì¦h¤@¦¸500±ø¡An¤À¬q©ñ¶i¥h
- Dim x, rcnt, i
- Dim sql_command As String
- Dim connection_string As String
-
- Worksheets(1).Activate
- rcnt = Range("a1").CurrentRegion.Rows.Count
- ¿¼Æ = (rcnt \ 500)
- zx = rcnt Mod 500 '§ä500¾l¼Æ
-
- j = 0
- If rcnt < 500 Then '¦pªG¤p©ó500®É¥upºâ¤U±¸ê®Æ
-
- aa = "insert into dbs(yyyymmdd, stockname, tradercode, price, buyamount, sellamount) values"
- Set x = CreateObject("adodb.recordset")
- cc = ""
- cc = aa
- i = 1
- For i = 1 To rcnt
- bb = "('" & Cells(i, 1) & "','" & Cells(i, 2) & "','" & Cells(i, 3) & "','" & Cells(i, 4) & "','" & Cells(i, 5) & "','" & Cells(i, 6) & "')"
- '¦ê±µninsertªº¼Æȹï
- cc = cc & bb & ","
- Next
-
- cc = Left(cc, Len(cc) - 1) '¨ú¦r¦ê¨Ã§R°£³Ì«á¤@Ó","
- sql_command = cc
- connection_string = ("Driver={SQLite3 ODBC Driver};database=D:\ªÑ²¼¸ê®Æ¤U¸ü\dbs.sqlite")
- x.Open sql_command, connection_string
- Set x = Nothing
- Else '¦pªG¤j©ó500®É¡Anºâ¤U±¨âºØ¸ê®Æ
-
- aa = "insert into dbs(yyyymmdd, stockname, tradercode, price, buyamount, sellamount) values"
- Set x = CreateObject("adodb.recordset")
- cc = ""
- cc = aa
- i = 1
- For i = 1 To zx
-
- bb = "('" & Cells(i, 1) & "','" & Cells(i, 2) & "','" & Cells(i, 3) & "','" & Cells(i, 4) & "','" & Cells(i, 5) & "','" & Cells(i, 6) & "')"
- cc = cc & bb & ","
- Next
- cc = Left(cc, Len(cc) - 1)
- sql_command = cc
- connection_string = ("Driver={SQLite3 ODBC Driver};database=D:\ªÑ²¼¸ê®Æ¤U¸ü\dbs.sqlite")
- x.Open sql_command, connection_string
- Set x = Nothing
- For j = 0 To ¿¼Æ - 1
-
- aa = "insert into dbs(yyyymmdd, stockname, tradercode, price, buyamount, sellamount) values"
- Set x = CreateObject("adodb.recordset")
- cc = ""
- cc = aa
- i = 1
-
- For i = j * 500 + zx + 1 To (j + 1) * 500 + zx
-
- bb = "('" & Cells(i + j * 500, 1) & "','" & Cells(i + j * 500, 2) & "','" & Cells(i + j * 500, 3) & "','" & Cells(i + j * 500, 4) & "','" & Cells(i + j * 500, 5) & "','" & Cells(i + j * 500, 6) & "')"
- cc = cc & bb & ","
-
- Next
-
- cc = Left(cc, Len(cc) - 1)
- sql_command = cc
- connection_string = ("Driver={SQLite3 ODBC Driver};database=D:\ªÑ²¼¸ê®Æ¤U¸ü\dbs.sqlite")
- x.Open sql_command, connection_string
- Set x = Nothing
- Next
-
- End If
- End Sub
½Æ»s¥N½X |
|