首页 > 学院 > 开发设计 > 正文

用MDB文件做admin888库

2019-11-18 17:46:47
字体:
来源:转载
供稿:网友
能用数据库做密码库吗?
这是我曾经编过的一段程序,从MDB数据库中提取regpass表中的内容,用一个datacombo控件列出常的用户名供选择,一个TEXTBOX供用户输入密码,大概思路如此,希望对你有帮助.
_______________________________________________
DimcnnPassAsNewADODB.Connection
DimrstPassAsNewADODB.Recordset
DimstrSQLAsString
DimLoginSucceededAsBoolean
PRivateSubcmdCancel_Click()
LoginSucceeded=False
UnloadMe
EndSub
_________________________________________
PrivateSubcmdOK_Click()
LSize=Len(CombUserName.Text)
IfLSize0Then
User=Left$(CombUserName.Text,LSize)
Else
User=vbNullString
EndIf
IfUser="管理员"Then
Pass=rstPass!PassWord
IftxtPassword.Text=PassThen
LoginSucceeded=True
Else
MsgBox"无效的密码,请重试!",vbExclamation vbOKOnly,"登录"
txtPassword.SetFocus
SendKeys"{Home} {End}"
EndIf
ElseIfUser="普通用户"Then
User="普通用户"
LoginSucceeded=True
'在此加入一些限制代码
UnloadMe
Else
MsgBox"非法用户!!!",,"登录"
CombUserName.SetFocus
txtPassword.SelLength=Len(txtPassword.Text)
SendKeys"{Home} {End}"
EndIf
EndSub
___________________________________________________
PrivateSubForm_Load()
DatName=App.Path&"/DBNAME.dll"
cnnPass.Provider="microsoft.jet.oledb.3.51"
cnnPass.OpenDatName,"admin"
strSQL="select*fromregpass"
rstPass.CursorLocation=adUseServer
rstPass.OpenstrSQL,cnnPass,adOpenKeyset,adLockReadOnly,adCmdText
WithCombUserName
Set.DataSource=rstPass
.DataField="UserName"
Set.RowSource=rstPass
.ListField="UserName"
.BoundColumn="UserName"
EndWith
CombUserName.Text="管理员"
EndSub

PrivateSubForm_Unload(CancelAsInteger)
IfrstPass.State=adStateOpenThen
rstPass.Close
SetrstPass=Nothing
EndIf
IfcnnPass.State=adStateOpenThen
cnnPass.Close
SetcnnPass=Nothing
EndIf

EndSub->


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表