测试txtUserName和txtPassword,与数据库的连接是否正确,为什么总提示错误?

berylw 2003-06-15 09:30:02
程序代码如下:(注:提示"缺少对象")
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

...全文
72 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
berylw 2003-06-15
  • 打赏
  • 举报
回复
没人理我?再up
berylw 2003-06-15
  • 打赏
  • 举报
回复
没定义conn,是别人帮我写的这段代码,我该在哪里声明?
berylw 2003-06-15
  • 打赏
  • 举报
回复
能否帮我重新写入一下全部的代码,我看不太懂你写的意思
sxs69 2003-06-15
  • 打赏
  • 举报
回复
conn在那里定义的
ydzqw 2003-06-15
  • 打赏
  • 举报
回复
project ->reference ->microsoft ado 2.6 library

引入ADO
berylw 2003-06-15
  • 打赏
  • 举报
回复
我是新学VB的,错误好象出在Private Sub cmdOK_Click()
ydzqw 2003-06-15
  • 打赏
  • 举报
回复
在哪一步的时候报错?
berylw 2003-06-15
  • 打赏
  • 举报
回复
我想实现的功能就是测试登陆框内的用户名和密码,与数据库里的是否能对应,如果“是”,就进入,“否”则提示错误。
ydzqw 2003-06-15
  • 打赏
  • 举报
回复
你没引入ADO吧?

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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