[求助] rs.fields EOF或BOF有一个是真或已被删除
idvalue
2001
2541
2506
这是excel表,里面有ID,value是空的,需要从数据库里选取value值然后填到excel表里,但是走到一半老是提示“rs.fields EOF或BOF有一个是真或已被删除”
rs.open "select id,value from table1",conn, adOpenForwardOnly, adLockReadOnly
While Not rs.EOF Or Not rs.BOF
for i=2 to sheet1.UsedRange.Rows.Count
if sheet1.cells(i,1)=rs.Fields("id").Value then
sheet1.cells(i,2)=rs.Fields("value").Value
end if
next i
rs.movenext
wend
rs.open "select id,value from table1",conn, adOpenForwardOnly, adLockReadOnly
do While Not rs.EOF
for i=2 to sheet1.UsedRange.Rows.Count
if sheet1.cells(i,1)=rs.Fields("id").Value then
sheet1.cells(i,2)=rs.Fields("value").Value
end if
next i
rs.movenext
loop