首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

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

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

实时错误 '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 ='" &amp; UserName &amp; "'"

if mrc.recordcount>0 then

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

热点排行