VB 连 SQL 出错 :对象变量或with块变量未设置

[复制链接]
查看11 | 回复2 | 2008-6-11 11:19:32 | 显示全部楼层 |阅读模式
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 mrc.EOF = True 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 mrc.EOF = True Then 出错提示: 对象变量或with块变量未设置
请问怎么解决??回答的好有追加!!谢谢!

回复

使用道具 举报

千问 | 2008-6-11 11:19:32 | 显示全部楼层
你链接数据库没有啊?你这也没有显示链接数据库的东西哦!
回复

使用道具 举报

千问 | 2008-6-11 11:19:32 | 显示全部楼层
还没有打开数据库,ExecuteSQL是什么?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行