用MDB文件做密码库

2008-02-23 06:52:16来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

能用数据库做密码库吗?
这是我曾经编过的一段程序,从MDB数据库中提取regpass表中的内容,用一个datacombo控件列出常的用户名供选择,一个TEXTBOX供用户输入密码,大概思路如此,希望对你有帮助.
_______________________________________________
Dim cnnPass As New ADODB.Connection
Dim rstPass As New ADODB.Recordset
Dim strSQL As String
Dim LoginSucceeded As Boolean
Private Sub cmdCancel_Click()
LoginSucceeded = False
Unload Me
End Sub
_________________________________________
Private Sub cmdOK_Click()
LSize = Len(CombUserName.Text)
If LSize 0 Then
User = Left$(CombUserName.Text, LSize)
Else
User = VBNullString
End If
If User = "管理员" Then
Pass = rstPass!Password
If txtPassword.Text = Pass Then
LoginSucceeded = True
Else
MsgBox "无效的密码,请重试!", vbExclamation vbOKOnly, "登录"
txtPassword.SetFocus
SendKeys "{Home} {End}"
End If
ElseIf User = "普通用户" Then
User = "普通用户"
LoginSucceeded = True
'在此加入一些限制代码
Unload Me
Else
MsgBox "非法用户!!!", , "登录"
CombUserName.SetFocus
txtPassword.SelLength = Len(txtPassword.Text)
SendKeys "{Home} {End}"
End If
End Sub
___________________________________________________
Private Sub Form_Load()
DatName = App.Path & "\DBNAME.dll"
cnnPass.Provider = "microsoft.jet.oledb.3.51"
cnnPass.Open DatName, "admin"
strSQL = "select * from regpass "
rstPass.CursorLocation = adUseServer
rstPass.Open strSQL, cnnPass, adOpenKeyset, adLockReadOnly, adCmdText
With CombUserName
Set .DataSource = rstPass
.DataField = "UserName"
Set .RowSource = rstPass
.ListField = "UserName"
.BoundColumn = "UserName"
End With
CombUserName.Text = "管理员"
End Sub

Private Sub Form_Unload(Cancel As Integer)
If rstPass.State = adStateOpen Then
rstPass.Close
Set rstPass = Nothing
End If
If cnnPass.State = adStateOpen Then
cnnPass.Close
Set cnnPass = Nothing
End If

End Sub

上一篇: VB应用程序访问SQL Server方法探讨
下一篇: 如何將Excel的文件导入Access文件

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:利用API播放 AVI

下一篇:用CELL组件显示Access数据库的图片对象