°õ¦æ¥X¿ù~§ä¤£¨ì¸ê®Æ©Î¸ê®Æ«¬ºA¿ù»~
- ©«¤l
- 1
- ¥DÃD
- 1
- ºëµØ
- 0
- ¿n¤À
- 7
- ÂI¦W
- 0
- §@·~¨t²Î
- win_xp
- ³nÅ骩¥»
- sp2
- ¾\ŪÅv
- 10
- ©Ê§O
- ¨k
- ¨Ó¦Û
- Taiwan
- µù¥U®É¶¡
- 2010-6-20
- ³Ì«áµn¿ý
- 2010-6-27
|
°õ¦æ¥X¿ù~§ä¤£¨ì¸ê®Æ©Î¸ê®Æ«¬ºA¿ù»~
¥»©«³Ì«á¥Ñ shenfu ©ó 2010-6-27 18:52 ½s¿è
Sub PopulateOneField()
Dim cnn As ADODB.Connection
Dim MyConn
Dim rst As ADODB.Recordset
Dim i As Long, j As Long
Dim Rw As Long
Dim sSQL As String
Dim sID As Long
Sheets("sheet1").Activate
Rw = Range("A65535").End(xlUp).Row
Set cnn = New ADODB.Connection
MyConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=D:\db.mdb;"
With cnn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open MyConn
End With
Set rst = New ADODB.Recordset
rst.CursorLocation = adUseServer
For i = 2 To 100
sID = Cells(i, 1).Value
sSQL = "select * from abc where abc.ID = " & sID
rst.Open Source:=sSQL, ActiveConnection:=cnn, _
CursorType:=adOpenKeyset, LockType:=adLockOptimistic
rst(Cells(1, 2).Value) = Cells(i, 2).Value
rst(Cells(1, 3).Value) = Cells(i, 3).Value
rst(Cells(1, 4).Value) = Cells(i, 4).Value
rst(Cells(1, 5).Value) = Cells(i, 5).Value
rst.Update
rst.Close
Next i
cnn.Close
Set rst = Nothing
Set cnn = Nothing
End Sub
¥H¤Wµ{¦¡°õ¦æ·|¥X¿ù
·Ç«h¹Bºâ¦¡ªº¸ê®ÆÃþ«¬¤£²Å¦X
¥i¬O§Ú³£§âid«¬ºA§ï¬°¤å¦r©Î¥þ§ï¼Æ¦r³£¨S¥Î¤]..
½Ð°Ý¦³¦ó¿ìªk¶Ü
§Úªºid³£¬Oaccess¤¤¦³ªº
¦Ó¦pªG§ï¦¨ ' " & sID & " '
¤]¬O·|¥X²{
=>¥i¯à¬O bof ©Î eof ªºÈ¬° true ©Î¥Ø«eªº¸ê®Æ¿ý¤w³Q§R°£ |
|
50 ¦r¸`¥H¤º
¤£¤ä«ù¦Û©w¸q Discuz! ¥N½X
|
|
|
|
|
- ©«¤l
- 172
- ¥DÃD
- 39
- ºëµØ
- 20
- ¿n¤À
- 177
- ÂI¦W
- 0
- §@·~¨t²Î
- Microsoft Windows XP
- ³nÅ骩¥»
- Microsoft Office 2003
- ¾\ŪÅv
- 100
- ©Ê§O
- ¨k
- ¨Ó¦Û
- °ª¶¯
- µù¥U®É¶¡
- 2010-5-1
- ³Ì«áµn¿ý
- 2023-3-19
|
¥»©«³Ì«á¥Ñ Min ©ó 2010-6-27 21:35 ½s¿è
¸Õ¸Õ¬Ý
sSQL = "select * from abc where abc.ID = '" & sID & "'" |
|
Y¬O§Ú¦^µª¡A¨Ï±zº¡·N¡A½Ð±zÅý§Úª¾¹D¡I
Y¬O§Úªº¦^ÂСA±z¤´¦³¨ä¥L¨£¸Ñ¡A¤]½Ð±z¤£¶Þ«ü±Ð¡I
|
|
|
|
|