- ©«¤l
- 552
- ¥DÃD
- 3
- ºëµØ
- 0
- ¿n¤À
- 578
- ÂI¦W
- 0
- §@·~¨t²Î
- win7
- ³nÅ骩¥»
- office 2010
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2015-2-8
- ³Ì«áµn¿ý
- 2024-7-9
|
¥»©«³Ì«á¥Ñ lpk187 ©ó 2017-2-19 20:20 ½s¿è
¥Î³oÓ¨Ò¤l§a¡I1¸Uµ§¸ê®Æ¬ù3¬í¡C³oÓinsert into ªº¥Îªk
¶×¤J¸ê®Æ¡A¤£¤@©w±o¥ÎSQL»y¥y- Public Sub ex()
- sql = "SELECT * FROM TblStudent ;"
- strSqlInstance = "¦øªA¾¹¦WºÙ"
- strSqlDB = "¸ê®Æ®w¦WºÙ"
- strSqlUser = "sa"
- strSqlPWD = "a123456"
- sConnect = "Provider=SQLOLEDB"
- sConnect = sConnect & ";Data Source=" & strSqlInstance & ";Initial Catalog=" & strSqlDB
- sConnect = sConnect & ";User ID=" & strSqlUser & ";Password=" & strSqlPWD & ";"
- Set myCon = CreateObject("ADODB.Connection")
- myCon.Open sConnect
- Set rng = Range("A2")
- With New ADODB.Recordset
- .Open sql, myCon, , adLockOptimistic
- Do Until rng = ""
- .AddNew
- For i = 1 To .Fields.Count - 1
- .Fields(i) = rng.Offset(, i - 1)
- Next
- Set rng = rng.Offset(1, 0)
- Loop
- .Update
- End With
- Set myRs = Nothing
- myCon.Close
- Set myCon = Nothing
- End Sub
½Æ»s¥N½X ¦^´_ 6# PKKO |
|