问一个关于access数据库的问题。在线等待。。。。
我用access建立一个数据库 database.mdb
其中 员工 表结构如下:
ID 姓名 职务 密码
001 张三 科员 123
002 李四 科员 123
003 王五 经理 123
现在想建一个登陆窗口,可以用combobox选择姓名,在textbox中输入对应密码,点CommandButton进入系统,请问如何实现密码从数据库中读取和效验??
万分感谢!!!
问题点数:0、回复次数:5Top
1 楼zlsunnan(深蓝)回复于 2003-11-04 19:44:10 得分 0
Dim txtSQL As String
Dim mrc As ADODB.Recordset
Dim MsgText As String
UserName = ""
If Trim(txtUserName.Text = "") Then
MsgBox "没有此用户,重新输入", vbOKOnly + vbExclamation,“信息提示”
txtUserName.SetFocus
Else
txtSQL = "select * from user_Info where user_ID = '" & txtUserName.Text & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = True Then
MsgBox "没有此用户,重新输入", vbOKOnly + vbExclamation, "信息提示"
txtUserName.SetFocus
Else
If Trim(mrc.Fields(1)) = Trim(txtPassword.Text) Then
OK = True
mrc.Close
Me.Hide
UserName = Trim(txtUserName.Text)
Else
MsgBox "密码输入错误!", vbOKOnly + vbExclamation, "信息提示"
txtPassword.SetFocus
txtPassword.Text = ""
End If
End If
End If
miCount = miCount + 1
If miCount = 3 Then
Me.Hide
End If
Exit Sub
End Sub
Top
2 楼zlsunnan(深蓝)回复于 2003-11-04 19:45:32 得分 0
漏了
Dim miCount As IntegerTop
3 楼ghosthy(ghost)回复于 2003-11-04 20:16:25 得分 0
我还是搞不懂。。。。 -_-#
能不能有大侠给我说清楚点呀,最好是非常详细的。。hoho。。谢谢了。Top
4 楼dengyiwolf(七星偃月刀)回复于 2003-11-04 21:03:26 得分 0
’将下列代码,放入你的COMMANDBUTTON中就行了。
dim rs_load as adodb.recordset
dim str_username as string
dim str_Password as string
dim str_combo1 as string
'判断是否选择了用户
if len(combo1.text)=0 then
msgbox "没有选择用户,请选择!"
exit sub
end if
'判断是否输入了6位的密码
if len(txtPassword)<>6 then
msgbox "输入有误,请输入6位有效的数字!"
exit sub
end if
'连接数据库。。。。。。(这一步该自己动手吧!!!)
'将用户名赋给字符串
str_combo1=trim(combo1.text)
set_password=trim(txtpassword.text)
set rs_load=new adodb.recordset
'从数据user表中提出所选择的用户名
str_username="select * from user where 用户名='"& str_combo1 &"'"
’打开记录集
with rs_load
.cursortype=3
.locktype=3
.open str_username,openconn
end with
'判断数据库里面是否有此用户
if rs_load.recordcount=0 then
msgbox "没有该用户,你是非法用户!"
rs_load.close
set rs_load =nothing
exit sub
end if
if val(rs_load.fields!用户密码)=val(str_password) then
进入。。。。。。。。。。。
else
msgbox "非法用户,密码不正确!"
endif
‘关闭记录集
rs_load.close
set rs_load =nothing
‘关闭连接Top
5 楼ghosthy(ghost)回复于 2003-11-04 21:11:00 得分 0
还是不会连接数据库。。。。我哭。。。。。。
各位表笑话我,哪儿有介绍vb数据库编程的书?Top
相关问题
- 急,在线等待 SQL Server2000 数据库倒入Access数据库!!!
- 请问如何将access数据库转为mysql数据库?急!在线等待!
- 如何修改ACCESS数据库的密码——在线等待
- *******用ASP连接ACCESS数据库的问题(在线等待)********
- 在线等待!pb中Access数据库问题,请指教!
- 在线等待。关于ACCESS数据库的问题?
- 关于ASP连ACCESS数据库的问题。在线等待。
- 如何破解加密的ACCESS数据库?(在线等待)
- Access 数据库过多字段的问题,在线等待!!!
- 大家帮忙:pb9的数据库anywhere8如何导入Access数据库?在线等待ing.....




