vb adodc1 连接数据库
是这样acess中账户是username密码是password表名是用户表vb中text1位账户text2位密码求一个登陆界面代码当账户密码与数据库匹配时form2.sh...
是这样 acess中账户是username 密码是password 表名是 用户表
vb中text1位账户 text2位密码
求一个登陆界面代码
当账户密码与数据库匹配时form2.show
下面是我自己写的但是一直显示账户密码错误
On Error Resume Next
Dim Psw As String
If Text1 = "" Or Text2 = "" Then
MsgBox "用户名密码不能为空,请重新输入!", 64, "提示"
Else
Adodc1.RecordSource = "select * from 用户表"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
usname = Adodc1.Recordset.Fields(UserName)
Psw = Adodc1.Recordset.Fields("Password")
If Text2.Text = Psw And Text1.Text = usname Then
Form2.Show
ElseIf Text2.Text <> Psw Then
MsgBox "密码错误,请重新输入!", 64, "提示": Text2 = "": Text2.SetFocus
End If
Else
MsgBox "没有该用户!", 64, "提示": Text1 = "": txtuser.SetFocus: Text2 = ""
End If 展开
vb中text1位账户 text2位密码
求一个登陆界面代码
当账户密码与数据库匹配时form2.show
下面是我自己写的但是一直显示账户密码错误
On Error Resume Next
Dim Psw As String
If Text1 = "" Or Text2 = "" Then
MsgBox "用户名密码不能为空,请重新输入!", 64, "提示"
Else
Adodc1.RecordSource = "select * from 用户表"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
usname = Adodc1.Recordset.Fields(UserName)
Psw = Adodc1.Recordset.Fields("Password")
If Text2.Text = Psw And Text1.Text = usname Then
Form2.Show
ElseIf Text2.Text <> Psw Then
MsgBox "密码错误,请重新输入!", 64, "提示": Text2 = "": Text2.SetFocus
End If
Else
MsgBox "没有该用户!", 64, "提示": Text1 = "": txtuser.SetFocus: Text2 = ""
End If 展开
3个回答
展开全部
Private Sub Command1_Click()
If Text1 = "" Or Text2 = "" Then
MsgBox "用户名密码不能为空,请重新输入!", 64, "提示"
Exit Sub
End If
Adodc1.RecordSource = "select * from 用户表 Where UserName='" & Text1.Text & "'"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
Psw = Adodc1.Recordset.Fields("Password")
If Text2.Text = Adodc1.Recordset.Fields("Password") Then
Unload Me
Form2.Show
ElseIf Text2.Text <> Psw Then
MsgBox "密码错误,请重新输入!", 64, "提示"
Text2 = ""
Text2.SetFocus
End If
Else
MsgBox "没有该用户!", 64, "提示"
Text1 = ""
Text1.SetFocus
Text2 = ""
End If
End Sub
追问
数据库表里面有内容但是不断报错 一直都是账户密码错误能加q 详谈么?
追答
数据库表里面有内容但是不断报错 一直都是账户密码错误,具体情况867235513详谈,提示:连接数据库
展开全部
中间一段代码有问题,改了一下:
Adodc1.RecordSource = "select * from 用户表 where username like '" & text1.text & "'"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
Psw = Adodc1.Recordset.Fields("Password")
If Text2.Text = Psw Then
Form2.Show
ElseIf Text2.Text <> Psw Then
MsgBox "密码错误,请重新输入!", 64, "提示": Text2 = "": Text2.SetFocus
End If
Else
MsgBox "没有该用户!", 64, "提示": Text1 = "": txtuser.SetFocus: Text2 = ""
End If
Adodc1.RecordSource = "select * from 用户表 where username like '" & text1.text & "'"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
Psw = Adodc1.Recordset.Fields("Password")
If Text2.Text = Psw Then
Form2.Show
ElseIf Text2.Text <> Psw Then
MsgBox "密码错误,请重新输入!", 64, "提示": Text2 = "": Text2.SetFocus
End If
Else
MsgBox "没有该用户!", 64, "提示": Text1 = "": txtuser.SetFocus: Text2 = ""
End If
追问
但是登陆窗口一直报错 显示账户名密码错误难道是acess 出错了?
追答
Psw = Adodc1.Recordset.Fields("Password")后加个msgbox(Psw),看显示出来的值是不是和你数据库里面的密码相同.
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询