数据库连接!

placj 2009-12-30 10:26:28
一个简单的登录代码,我用ACCESS做数据库时没问题,但换成SQL2000后 代码一样 每次点击登录时只能判断到用户名,密码我输入正确的他也提示错误晕死!请问为什么?是不是SQL2000我建表时数据类型不对?
代码如下:
Private Sub cmdDL_Click()
Static miCount As Integer
If txtUserName = "" Then
MsgBox "用户名不能为空,请重输入!", vbExclamation + vbOKOnly, "系统提示!"
txtUserName.SetFocus
Exit Sub
End If

txtSQL = "select * from User_Info where User_Name='" & txtUserName & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF Then
MsgBox "用户名不正确,请重新输入!", vbExclamation + vbOKOnly, "系统提示!"
txtUserName = ""
txtPassword.Enabled = False
txtUserName.SetFocus
Exit Sub
Else
txtPassword.Enabled = True
End If

If txtPassword <> "" Then
Debug.Print (mrc.Fields("User_Password"))
If mrc.Fields("User_Password") <> txtPassword Then
MsgBox "密码错误,请重新输入!", vbExclamation + vbOKOnly, "系统提示!"
txtPassword = ""
txtPassword.SetFocus
miCount = miCount + 1
If miCount >= 3 Then
MsgBox "无权操作本系统!再见!", vbOKOnly + vbExclamation, "警告"
End
End If
Else
frmMainMDI.Show
Unload frmLogin
End If
Else
End If

If txtUserName <> "" Then
txtPassword.SetFocus
Exit Sub
End If
End Sub
...全文
36 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
placj 2009-12-30
  • 打赏
  • 举报
回复
恩,正确给分!
placj 2009-12-30
  • 打赏
  • 举报
回复
输出密码正确的我试试楼上的
bancxc 2009-12-30
  • 打赏
  • 举报
回复
Debug.Print (mrc.Fields( "User_Password "))
输出的密码对吗?
bancxc 2009-12-30
  • 打赏
  • 举报
回复
你的User_Info的字段User_Password 是什么类型的
用varchar 或varchar
char可能会有空格补齐的

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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