VB 实时错误'91' 对象变量或with块变量未设置

来源:百度知道 编辑:UC知道 时间:2024/06/01 07:48:30
代码如下:
Private Sub cmdOK_Click()
'检查正确的密码
Dim txtsql As String
Dim msgtxt As String
Dim mrc As ADODB.Recordset
If Len(txtPassword) <> 0 Then
'将代码放在这里传递
'成功到 calling 函数
'设置全局变量时最容易的
txtsql = "select * from LIMITATION where Lid='" + txtUserName.Text + "' and Lpassword='" + txtPassword.Text + "'"
Set mrc = ExecuteSQL(txtsql, msgtxt)
If Not mrc.EOF Then
ok = True
Me.Hide
Else
MsgBox "无效的用户名或密码!", , "提示"
txtUserName.SetFocus
SendKeys "{home}+{end}"
End If
Else
MsgBox "无效的密码,请重试!", , "登录"
txtPassword.SetFocus
SendKeys "{Home}+{End}"
End If
End Sub

sql数据库已经练好了,但是运行vb程序的时候提示:实时错误&

If Not mrc.EOF Then

not(非) 少东西

例: NOT(3>8) 则 等于 false
如果 not(3<8) 则 等于 true

是不是mrc.EOF没有值 ?
我在美国学的 所以不是很知道怎么说 = =

加上这句把Recordset 对象实体化
set mrc = new ADODB.Recordset