7 个解决方案
#1
Private Sub Command1_Click()
Set reco = New ADODB.Recordset
Trim(Text1.Text) & "'", Con, adOpenDynamic, adLockOptimistic
If Text1.Text = "" Then
MsgBox ("请输入用户名!!!")
Text1.SetFocus
Else
reco.Open "select staff_id,password,name from staff where staff_id='" & Trim(Text1.Text) & "'", Con, adOpenDynamic, adLockOptimistic
If reco.EOF Then
MsgBox ("用户名不存在!!!!")
Else
hxc_staff_id = reco(0)
hxc_password = reco(1)
user_name = reco(2)
If Text2.Text = hxc_password Then
reco.Close
Unload Me
form2.Show
form2.Text1.SetFocus
Else
MsgBox ("密码不正确!!!!")
End If
End If
End If
end sub
把 sql改成你的字段名和表名就可以了。我想你会连数据库吧!
Set reco = New ADODB.Recordset
Trim(Text1.Text) & "'", Con, adOpenDynamic, adLockOptimistic
If Text1.Text = "" Then
MsgBox ("请输入用户名!!!")
Text1.SetFocus
Else
reco.Open "select staff_id,password,name from staff where staff_id='" & Trim(Text1.Text) & "'", Con, adOpenDynamic, adLockOptimistic
If reco.EOF Then
MsgBox ("用户名不存在!!!!")
Else
hxc_staff_id = reco(0)
hxc_password = reco(1)
user_name = reco(2)
If Text2.Text = hxc_password Then
reco.Close
Unload Me
form2.Show
form2.Text1.SetFocus
Else
MsgBox ("密码不正确!!!!")
End If
End If
End If
end sub
把 sql改成你的字段名和表名就可以了。我想你会连数据库吧!
#2
第三行是没用的,请不要COPY!写错了!不好意思!
#3
我看需要一个循环使输入的用户名与密码和数据库里已有的进行一一对比,如果数据库里有,就进入另外一个窗口,如果没有,则提示错误信息.
#4
可以把输入的用户名和密码当成条件来进行sql查询,如果返回记录值为0说明有错误,不能进入主界面,否则就有,当然更清楚的,你可以先判断有无此用户,仍然用sql查询去做,在有对应用户时加密码条件再查,如果返回记录数为0说明密码有误,仍然不能进入,返回1(这里假设一个用户名一个密码,所以说要求返回1)可以进入。
说的比较乱,但是大概思路就是这样,不难,你自己试试吧!
说的比较乱,但是大概思路就是这样,不难,你自己试试吧!
#5
Private Sub CmdQD_Click()
Dim reco As New Recordset
If InUserCom.Text = "" Then
MsgBox ("请输入用户名!!!")
InUserCom.SetFocus
Else
reco.Open "select usrname,pwd, from Manager where usrname='" & Trim(Text1.Text) & "'", Con, adOpenDynamic, adLockOptimistic
If reco.EOF Then
MsgBox ("用户名不存在!!!!")
Else
usrname = reco(0)
pwd = reco(1)
If InPwdText.Text = pwd Then
reco.Close
If pwd = "admin" Then
MsgBox "你是系统管理员,欢迎使用本系统!", vbExclamation
Unload Me
学生信息管理.Show
Else
MsgBox "你是客户,欢迎浏览本系统!", vbExclamation
Unload Me
学生信息管理.Show
End If
End If
End If
End If
End Sub
但提示我类型不匹配啊?大家看一下问题出在哪里?
Dim reco As New Recordset
If InUserCom.Text = "" Then
MsgBox ("请输入用户名!!!")
InUserCom.SetFocus
Else
reco.Open "select usrname,pwd, from Manager where usrname='" & Trim(Text1.Text) & "'", Con, adOpenDynamic, adLockOptimistic
If reco.EOF Then
MsgBox ("用户名不存在!!!!")
Else
usrname = reco(0)
pwd = reco(1)
If InPwdText.Text = pwd Then
reco.Close
If pwd = "admin" Then
MsgBox "你是系统管理员,欢迎使用本系统!", vbExclamation
Unload Me
学生信息管理.Show
Else
MsgBox "你是客户,欢迎浏览本系统!", vbExclamation
Unload Me
学生信息管理.Show
End If
End If
End If
End If
End Sub
但提示我类型不匹配啊?大家看一下问题出在哪里?
#6
用数据库来保存密错。我建议你最好把数据库加密!
#7
Option Explicit
'引用microsoft actionx data objects 2.0 library
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Dim str As String
Private Sub cmdOK_Click()
'我这里是从access数据库房屋信息表中的房主信息中读入用户名和密码和输入的进行比较
str = "SELECT * FROM 房主信息 where pername='" & txtUserName.Text & "'and password='" & txtPassword.Text & "'"
Set con = New ADODB.Connection
Set rs = New ADODB.Recordset
con.Provider = "Microsoft.Jet.OLEDB.4.0"
con.Open App.Path & "\房屋信息表.MDB"
rs.Open str, con, adOpenDynamic, adLockOptimistic
wxyname = Trim(txtUserName.Text)
wxypass = Trim(txtPassword.Text)
If rs.EOF And rs.BOF Then
MsgBox "用户名或密码错误,再试一次!", , "登录"
txtUserName.SetFocus
txtUserName.SelStart = 0
txtUserName.SelLength = Len(txtPassword.Text)
Else
'你想干吗就去做
End If
End Sub
'引用microsoft actionx data objects 2.0 library
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Dim str As String
Private Sub cmdOK_Click()
'我这里是从access数据库房屋信息表中的房主信息中读入用户名和密码和输入的进行比较
str = "SELECT * FROM 房主信息 where pername='" & txtUserName.Text & "'and password='" & txtPassword.Text & "'"
Set con = New ADODB.Connection
Set rs = New ADODB.Recordset
con.Provider = "Microsoft.Jet.OLEDB.4.0"
con.Open App.Path & "\房屋信息表.MDB"
rs.Open str, con, adOpenDynamic, adLockOptimistic
wxyname = Trim(txtUserName.Text)
wxypass = Trim(txtPassword.Text)
If rs.EOF And rs.BOF Then
MsgBox "用户名或密码错误,再试一次!", , "登录"
txtUserName.SetFocus
txtUserName.SelStart = 0
txtUserName.SelLength = Len(txtPassword.Text)
Else
'你想干吗就去做
End If
End Sub
#1
Private Sub Command1_Click()
Set reco = New ADODB.Recordset
Trim(Text1.Text) & "'", Con, adOpenDynamic, adLockOptimistic
If Text1.Text = "" Then
MsgBox ("请输入用户名!!!")
Text1.SetFocus
Else
reco.Open "select staff_id,password,name from staff where staff_id='" & Trim(Text1.Text) & "'", Con, adOpenDynamic, adLockOptimistic
If reco.EOF Then
MsgBox ("用户名不存在!!!!")
Else
hxc_staff_id = reco(0)
hxc_password = reco(1)
user_name = reco(2)
If Text2.Text = hxc_password Then
reco.Close
Unload Me
form2.Show
form2.Text1.SetFocus
Else
MsgBox ("密码不正确!!!!")
End If
End If
End If
end sub
把 sql改成你的字段名和表名就可以了。我想你会连数据库吧!
Set reco = New ADODB.Recordset
Trim(Text1.Text) & "'", Con, adOpenDynamic, adLockOptimistic
If Text1.Text = "" Then
MsgBox ("请输入用户名!!!")
Text1.SetFocus
Else
reco.Open "select staff_id,password,name from staff where staff_id='" & Trim(Text1.Text) & "'", Con, adOpenDynamic, adLockOptimistic
If reco.EOF Then
MsgBox ("用户名不存在!!!!")
Else
hxc_staff_id = reco(0)
hxc_password = reco(1)
user_name = reco(2)
If Text2.Text = hxc_password Then
reco.Close
Unload Me
form2.Show
form2.Text1.SetFocus
Else
MsgBox ("密码不正确!!!!")
End If
End If
End If
end sub
把 sql改成你的字段名和表名就可以了。我想你会连数据库吧!
#2
第三行是没用的,请不要COPY!写错了!不好意思!
#3
我看需要一个循环使输入的用户名与密码和数据库里已有的进行一一对比,如果数据库里有,就进入另外一个窗口,如果没有,则提示错误信息.
#4
可以把输入的用户名和密码当成条件来进行sql查询,如果返回记录值为0说明有错误,不能进入主界面,否则就有,当然更清楚的,你可以先判断有无此用户,仍然用sql查询去做,在有对应用户时加密码条件再查,如果返回记录数为0说明密码有误,仍然不能进入,返回1(这里假设一个用户名一个密码,所以说要求返回1)可以进入。
说的比较乱,但是大概思路就是这样,不难,你自己试试吧!
说的比较乱,但是大概思路就是这样,不难,你自己试试吧!
#5
Private Sub CmdQD_Click()
Dim reco As New Recordset
If InUserCom.Text = "" Then
MsgBox ("请输入用户名!!!")
InUserCom.SetFocus
Else
reco.Open "select usrname,pwd, from Manager where usrname='" & Trim(Text1.Text) & "'", Con, adOpenDynamic, adLockOptimistic
If reco.EOF Then
MsgBox ("用户名不存在!!!!")
Else
usrname = reco(0)
pwd = reco(1)
If InPwdText.Text = pwd Then
reco.Close
If pwd = "admin" Then
MsgBox "你是系统管理员,欢迎使用本系统!", vbExclamation
Unload Me
学生信息管理.Show
Else
MsgBox "你是客户,欢迎浏览本系统!", vbExclamation
Unload Me
学生信息管理.Show
End If
End If
End If
End If
End Sub
但提示我类型不匹配啊?大家看一下问题出在哪里?
Dim reco As New Recordset
If InUserCom.Text = "" Then
MsgBox ("请输入用户名!!!")
InUserCom.SetFocus
Else
reco.Open "select usrname,pwd, from Manager where usrname='" & Trim(Text1.Text) & "'", Con, adOpenDynamic, adLockOptimistic
If reco.EOF Then
MsgBox ("用户名不存在!!!!")
Else
usrname = reco(0)
pwd = reco(1)
If InPwdText.Text = pwd Then
reco.Close
If pwd = "admin" Then
MsgBox "你是系统管理员,欢迎使用本系统!", vbExclamation
Unload Me
学生信息管理.Show
Else
MsgBox "你是客户,欢迎浏览本系统!", vbExclamation
Unload Me
学生信息管理.Show
End If
End If
End If
End If
End Sub
但提示我类型不匹配啊?大家看一下问题出在哪里?
#6
用数据库来保存密错。我建议你最好把数据库加密!
#7
Option Explicit
'引用microsoft actionx data objects 2.0 library
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Dim str As String
Private Sub cmdOK_Click()
'我这里是从access数据库房屋信息表中的房主信息中读入用户名和密码和输入的进行比较
str = "SELECT * FROM 房主信息 where pername='" & txtUserName.Text & "'and password='" & txtPassword.Text & "'"
Set con = New ADODB.Connection
Set rs = New ADODB.Recordset
con.Provider = "Microsoft.Jet.OLEDB.4.0"
con.Open App.Path & "\房屋信息表.MDB"
rs.Open str, con, adOpenDynamic, adLockOptimistic
wxyname = Trim(txtUserName.Text)
wxypass = Trim(txtPassword.Text)
If rs.EOF And rs.BOF Then
MsgBox "用户名或密码错误,再试一次!", , "登录"
txtUserName.SetFocus
txtUserName.SelStart = 0
txtUserName.SelLength = Len(txtPassword.Text)
Else
'你想干吗就去做
End If
End Sub
'引用microsoft actionx data objects 2.0 library
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Dim str As String
Private Sub cmdOK_Click()
'我这里是从access数据库房屋信息表中的房主信息中读入用户名和密码和输入的进行比较
str = "SELECT * FROM 房主信息 where pername='" & txtUserName.Text & "'and password='" & txtPassword.Text & "'"
Set con = New ADODB.Connection
Set rs = New ADODB.Recordset
con.Provider = "Microsoft.Jet.OLEDB.4.0"
con.Open App.Path & "\房屋信息表.MDB"
rs.Open str, con, adOpenDynamic, adLockOptimistic
wxyname = Trim(txtUserName.Text)
wxypass = Trim(txtPassword.Text)
If rs.EOF And rs.BOF Then
MsgBox "用户名或密码错误,再试一次!", , "登录"
txtUserName.SetFocus
txtUserName.SelStart = 0
txtUserName.SelLength = Len(txtPassword.Text)
Else
'你想干吗就去做
End If
End Sub