读书人

实时异常 #039;3021#039; eof或eof 中有一个是

发布时间: 2012-04-04 16:38:51 作者: 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
[解决办法]
直接用DB.EXECUTE "UPDATE XXX SET XXX WHERE XXX"
[解决办法]
mrc.recordcount =0 没有查询到数据
[解决办法]
UserName
[解决办法]

探讨
txtSQL = "select * from user_info where user_ID ='" & UserName & "'"

if mrc.recordcount>0 then

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

读书人网 >VB

热点推荐