测试txtUserName和txtPassword,与数据库的连接是否正确,为什么总提示错误?
程序代码如下:(注:提示"缺少对象")
Private Sub cmdOK_Click()
Dim strSQL As String
Dim rs As ADODB.Recordset
On Error GoTo proc_Err
'检查密码
strSQL = "select * from login where vEmployeeID='" & Trim(txtUserName) & "'and vpassword='" & Trim(txtPassword) & "'"
Set rs = conn.Execute(strSQL)
If rs.BOF = True Then
MsgBox "密码无效,请重新输入!", , "Login"
m_intDLCS = m_intDLCS + 1
If m_intDLCS > 3 Then
Unload Me
End If
txtPassword.SetFocus
SendKeys "{Home}+{End}"
Else
'初始化菜单
LoginSucceeded = True
Unload Me
End If
proc_Exit:
Set rs = Nothing
Exit Sub
proc_Err:
MsgBox Err.Description, vbInformation, App.Title
Err.Clear
GoTo proc_Exit
End Sub