读书人

实时异常 amp;#x27;3021amp;#x27; eof或eof

发布时间: 2012-12-14 10:33:07 作者: rapoo

实时错误 '3021' eof或eof 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录
当我运行程序时,就会显示 实时错误 '3021' eof或eof 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录
源代码如下:
Private Sub cmdOK_Click()
Dim txtSQL As String
Dim MsgText As String
Dim mrc As ADODB.Recordset

If Trim(Text1(0).Text) <> Trim(Text1(1).Text) Then
MsgBox "两次输入的密码不一样!", vbOKOnly + vbExclamation, "警告"
Text1(0).SetFocus
Text1(0).Text = ""
Text1(1).Text = ""
Else
txtSQL = "select*from user_info where user_ID ='" & UserName & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)

mrc.Fields(1) = Text1(1).Text
mrc.Update
mrc.Close
MsgBox "密码修改成功!", vbOKOnly + vbExclamation, "警告"
Me.Hide
End If

End Sub

[最优解释]
txtSQL = "select * from user_info where user_ID ='" & UserName & "'"

if mrc.recordcount>0 then

mrc.Fields(1) = Text1(1).Text
....
end if
[其他解释]
mrc.recordcount =0 没有查询到数据
[其他解释]

引用:
txtSQL = "select * from user_info where user_ID ='" & UserName & "'"

if mrc.recordcount>0 then

mrc.Fields(1) = Text1(1).Text
....
end if


txtSQL = "select * from user_info where user_ID ='" & UserName & "'"
应该要加入:
mrc.open txtSql,cnn'假设mrc已经new创建,cnn已经打开

if mrc.recordcount>0 then

mrc.Fields(1) = Text1(1).Text
....
end if
[其他解释]
直接用DB.EXECUTE "UPDATE XXX SET XXX WHERE XXX"
[其他解释]
UserName
[其他解释]
看看ExecuteSQL函数中是否使用了客户端游标。

读书人网 >VB

热点推荐