07

08

vb登录代码(读取SQL数据库,Md5加密)

今晚写的vb登录代码,读取SQL数据库,Md5加密
程序代码 程序代码

SqlLocalName = "(local)"    '连接IP  [ 本地用 (local) 外地用IP ]
SqlUserName = "kanoe.cn"         '用户名
SqlPassword = "kanoe.cn"          '用户密码
SqlDatabaseName = "kanoe.cn"     '数据库名
connstr = "Provider=Sqloledb;User ID=" & SqlUserName & "; Password=" & SqlPassword & "; Initial CataLog = " & SqlDatabaseName & "; Data Source=" & SqlLocalName & ";"
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
On Error Resume Next
Set conn = New ADODB.Connection
conn.Open connstr
If Err Then
Err.Clear
Set conn = Nothing
MsgBox "数据库连接出错,请检查连接字串。"
Exit Sub
End If

Dim Rs As ADODB.Recordset
Set Rs = New ADODB.Recordset
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
sqlstr = "Select [UserName],[Password],[Groups] FROM [User] Where [UserName] = '" + Text1.Text + "'"
Rs.Open sqlstr, conn, adOpenStatic, adLockReadOnly, adCmdText

Dim Authenticated As Boolean
Dim cl As Md5
Set cl = New Md5   'class 为你存的类模快名
Authenticated = False
If Rs.EOF = True And Rs.BOF Then
MsgBox "用户不存在!"
Rs.Close
Else
If LCase(cl.Md5_String_Calc(Text2.Text, 16)) = Rs("Password") Then
Authenticated = True
Rs.Close
Else
MsgBox "密码错误"
Rs.Close
End If
End If

If Authenticated = True Then
Form2.Hide
Form1.Show
End If



[本日志由 独木舟 于 2008-10-09 04:01 PM 编辑]
文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags: Code
相关日志:
评论: 0 | 引用: 0 | 查看次数: -
发表评论
昵 称:
密 码: 游客发言不需要密码.
内 容:
验证码: 验证码
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.