实时错误‘91’,对象变量或with块变量未设置

chenjunnnnnn 2009-06-08 11:35:19
Private Sub cmdOK_Click()
Dim txtSQL As String
Dim mrc As ADODB.Recordset
Dim MsgText As String
'ToDo: create test for correct password
'check for correct password

UserName = ""
If Trim(txtUserName.Text = "") Then
MsgBox "用户名不允许为空,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
txtUserName.SetFocus
Else
txtSQL = "select * from user_Info where user_ID = '" & txtUserName.Text & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If Not mrc.EOF Then
MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
txtUserName.SetFocus
Else
If Trim(mrc.Fields(1)) = Trim(txtPassword.Text) Then
OK = True
mrc.Close
Me.Hide
UserName = Trim(txtUserName.Text)
Else
MsgBox "输入密码不正确,请重新输入!", vbOKOnly + vbExclamation, "警告"
txtPassword.SetFocus
txtPassword.Text = ""
End If
End If
End If

miCount = miCount + 1
If miCount = 3 Then
Me.Hide
End If
Exit Sub
End Sub

报出错的是: If Not mrc.EOF Then,大侠帮帮忙看看,不胜感激!!!!!!
...全文
74 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
chenjunnnnnn 2009-06-09
  • 打赏
  • 举报
回复
换了还是报原来的错!
chenjunnnnnn 2009-06-09
  • 打赏
  • 举报
回复
?????[Quote=引用 4 楼 dj3688 的回复:]
引用楼主 chenjunnnnnn 的帖子:
Dim txtSQL As String
Dim mrc As ADODB.Recordset

...

txtSQL = "select * from user_Info where user_ID = '" & txtUserName.Text & "'"
Set mrc = cn.Execute(txtSQL)



try..
[/Quote]
dj3688 2009-06-09
  • 打赏
  • 举报
回复
[Quote=引用楼主 chenjunnnnnn 的帖子:]
Dim txtSQL As String
Dim mrc As ADODB.Recordset

...

txtSQL = "select * from user_Info where user_ID = '" & txtUserName.Text & "'"
Set mrc = cn.Execute(txtSQL)
[/Quote]

try..
-晴天 2009-06-08
  • 打赏
  • 举报
回复
If Not mrc.EOF Then
MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
txtUserName.SetFocus
Else
If Trim(mrc.Fields(1)) = Trim(txtPassword.Text) Then
OK = True
mrc.Close
Me.Hide
UserName = Trim(txtUserName.Text)
Else
MsgBox "输入密码不正确,请重新输入!", vbOKOnly + vbExclamation, "警告"
txtPassword.SetFocus
txtPassword.Text = ""
End If
End If
反了.
If Not mrc.EOF Then
If Trim(mrc.Fields(1)) = Trim(txtPassword.Text) Then
OK = True
mrc.Close
Me.Hide
UserName = Trim(txtUserName.Text)
Else
MsgBox "输入密码不正确,请重新输入!", vbOKOnly + vbExclamation, "警告"
txtPassword.SetFocus
txtPassword.Text = ""
End If
Else
MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
txtUserName.SetFocus
End If
dj3688 2009-06-08
  • 打赏
  • 举报
回复
Dim mrc As new ADODB.Recordset

try..?

34,873

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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