仓木麻衣照片:这个错误是怎么回事啊?

来源:百度文库 编辑:中科新闻网 时间:2024/05/09 19:49:07
Private Sub cmdOK_Click()

If Text1.Text = "" Or Text2.Text = "" Then
MsgBox "用户名或密码不能为空", vbOKOnly, "警告"
Text1.SetFocus
End If

If Text1.Text = Adodc1.Recordset.Fields("username").Value And Text2.Text = Adodc1.Recordset.Fields("password").Value Then
Form2.Show
Me.Hide
Else
MsgBox "用户名或密码错误", vbOKOnly, "错误提示"
End If
If Adodc1.Recordset.EOF = True Then
MsgBox "无此用户", vbOKOnly, "提示"
Text1.SetFocus
End If
End Sub
运行后,一输入用户名,密码点击登陆后就提示“对象变量或with块变量未设置”这是哪里有问题啊?
调试时是显示If Text1.Text = Adodc1.Recordset.Fields("username").Value And Text2.Text = Adodc1.Recordset.Fields("password").Value Then
这句的问题

Adodc的密码登陆
Adodc1.RecordSource = "select * from 表名 where username='" & Text1.Text & "'and password='" & Text2.Text & "'"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount = 0 Then
MsgBox "用户名或密码错误", 16, "错误提示"
Text1.SetFocus
Else
Form2.Show
Me.Hide
End If