用MDB文件做admin888库
今天图老师小编要跟大家分享用MDB文件做admin888库,精心挑选的过程简单易学,喜欢的朋友一起来学习吧!
这是我曾经编过的一段程序,从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->