| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 866 人关注过本帖
标题:求助 设计用户登录 密码没错 老是显示密码错误
取消只看楼主 加入收藏
ruoyufan
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2015-4-14
结帖率:0
收藏
已结贴  问题点数:20 回复次数:1 
求助 设计用户登录 密码没错 老是显示密码错误
Private Sub cmdOK_Click()

txtUserName.Text = Trim(txtUserName.Text)
If txtUserName.Text = "" Then
   MsgBox " 请输入用户名!"
   Exit Sub
End If

txtPassword.Text = Trim(txtPassword.Text)
If txtPassword.Text = "" Then
   MsgBox " 请输入密码!"
   Exit Sub
End If

Dim msg, style, title, response

Dim Conn As New ADODB.Connection     '声明并实例化连接数据库对象 -- 用来连接数据库文件,并对数据库以及数据表的操作
Dim Rst As New ADODB.Recordset       '声明并实例化数据记录集对象 -- 用来返回数据记录集,并对记录的操作

'执行 ADODB.Connection对象的Open方法,完成数据库的连接
Conn.Open SQLConnecTionString1

'执行 ADODB.Recordset对象的Open方法,获得记录集
Rst.Open "Select * From 用户 Where 用户名='" & txtUserName.Text & "'", Conn, adOpenKeyset, adLockPessimistic
If Not (Rst.RecordCount >= 1) Then
   MsgBox "数据表记录为0!"
   End
End If

If Not (Rst.EOF And Rst.BOF) Then
   '检查正确的密码
   If Rst.Fields("密码") = txtPassword.Text Then
      Unload Me
      Form1.Show
   Else
      msg = "错误的登录密码!" & Chr(13) & Chr(10) & Chr(13) & Chr(10)
      style = vbRetryCancel + vbExclamation + vbDefaultButton1
      title = "提示"
      response = MsgBox(msg, style, title)
      If response = vbRetry Then
         Exit Sub
      ElseIf response = vbCancel Then
         End
      End If
   End If
Else
   msg = "错误的用户名!" & Chr(13) & Chr(10) & Chr(13) & Chr(10)
      style = vbRetryCancel + vbExclamation + vbDefaultButton1
      title = "提示"
      response = MsgBox(msg, style, title)
      If response = vbRetry Then
         Exit Sub
      ElseIf response = vbCancel Then
         End
      End If
End If

End Sub
搜索更多相关主题的帖子: 连接数据库 用户登录 输入密码 用户名 数据表 
2015-04-14 19:00
ruoyufan
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2015-4-14
收藏
得分:0 
新人求帮助
2015-04-14 19:08
快速回复:求助 设计用户登录 密码没错 老是显示密码错误
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015228 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved