实时错误 '3021' eof或eof 中有一个是“真”,或者当前的记录已被删除,所需的操作要求一个当前的记录

刘正权 2011-07-19 03:46:40
当我运行程序时,就会显示 实时错误 '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
...全文
102 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
chinaboyzyq 2011-08-19
  • 打赏
  • 举报
回复
看看ExecuteSQL函数中是否使用了客户端游标。
worldy 2011-08-19
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 clear_zero 的回复:]
txtSQL = "select * from user_info where user_ID ='" & UserName & "'"

if mrc.recordcount>0 then

mrc.Fields(1) = Text1(1).Text
....
end if
[/Quote]

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
chinaboyzyq 2011-08-18
  • 打赏
  • 举报
回复
UserName
xc_aspnet 2011-08-18
  • 打赏
  • 举报
回复
mrc.recordcount =0 没有查询到数据
熊孩子开学喽 2011-08-06
  • 打赏
  • 举报
回复
直接用DB.EXECUTE "UPDATE XXX SET XXX WHERE XXX"
clear_zero 2011-07-19
  • 打赏
  • 举报
回复
txtSQL = "select * from user_info where user_ID ='" & UserName & "'"

if mrc.recordcount>0 then

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

1,502

社区成员

发帖
与我相关
我的任务
社区描述
VB 网络编程
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧