各位大虾,救救我!
下面一段示例代码当运行到 rst.MoveFirst
时就死机,CPU使用率100% ,rst中是有记录的,把 rst.MoveFirst改成movenext,movelast等也一样
如果不用move..,就能运行。
反正rst就是不能移动,为什么啊!!!!大家有没有遇到过这种情况啊
救救我吧!Private Sub Command1_Click()
Dim mrc As ADODB.Recordset
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim SQL As StringSet cnn = New ADODB.Connection
cnn.ConnectionTimeout = 5
cnn.Open "filedsn=youyi.dsn;uid=sa;pwd="
Set rst = New ADODB.Recordset
SQL = "select * from vender"
rst.Open Trim$(SQL), cnn, adOpenKeyset, adLockOptimistic
MsgBox "查询到" & rst.RecordCount & "条记录!"
If rst.EOF = False Then rst.MoveFirst Do While mrc.EOF = False
MsgBox mrc.Fields(0)
rst.MoveNext
Loop
End If
Set rst = Nothing
Set cnn = Nothing
End Sub
下面一段示例代码当运行到 rst.MoveFirst
时就死机,CPU使用率100% ,rst中是有记录的,把 rst.MoveFirst改成movenext,movelast等也一样
如果不用move..,就能运行。
反正rst就是不能移动,为什么啊!!!!大家有没有遇到过这种情况啊
救救我吧!Private Sub Command1_Click()
Dim mrc As ADODB.Recordset
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim SQL As StringSet cnn = New ADODB.Connection
cnn.ConnectionTimeout = 5
cnn.Open "filedsn=youyi.dsn;uid=sa;pwd="
Set rst = New ADODB.Recordset
SQL = "select * from vender"
rst.Open Trim$(SQL), cnn, adOpenKeyset, adLockOptimistic
MsgBox "查询到" & rst.RecordCount & "条记录!"
If rst.EOF = False Then rst.MoveFirst Do While mrc.EOF = False
MsgBox mrc.Fields(0)
rst.MoveNext
Loop
End If
Set rst = Nothing
Set cnn = Nothing
End Sub
MsgBox mrc.Fields(0)
rst.MoveNext
Loop
改成:
Do While rst.EOF = False
MsgBox rst.Fields(0)
rst.MoveNext
Loop
在你的程序中根本就没有用到mrc
为什么要在do while 中用到 mrc.movenext,可能是这将程序变成死循环
Set cnn = New ADODB.Connection
cnn.ConnectionTimeout = 5
cnn.Open "filedsn=youyi.dsn;uid=sa;pwd="
Set rst = New ADODB.Recordset
SQL = "select * from vender"
rst.Open Trim$(SQL), cnn, adOpenKeyset, adLockOptimistic
MsgBox "查询到" & rst.RecordCount & "条记录!"
do while not rst.eof
MsgBox rst.Fields(0)
rst.movenext
loopSet rst = Nothing
Set cnn = Nothing
End
到rst.movenext死掉了!
55,不是代码的问题,不知道是什么问题
大家帮帮我啊!
While rst.EOF = False
MsgBox rst.Fields(0)
rst.MoveNext
Wend
应该不会有错了
with rst
while not.eof
msgbox rst.fields(0)
.movenext
wend
end with
这样试试,应该没什么事的,实在不行的话,单步调试一下,看看哪里出的问题