请看这里!高手们帮我翻译下这段程序~~~我急用 万分谢谢啦!

LIU891666 2010-10-26 09:49:54
请逐条解释~~~~~~~谢谢!谢谢!



Private Function Check_PassWord() As Byte
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim connstr
connstr = "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & App.Path & "\db1.mdb;"
conn.Open connstr
username = Trim(username.Text)
password = Trim(password.Text)
strSQL = "SELECT * FROM 系统用户 WHERE username='" & username & "'"
Set objRs = conn.Execute(strSQL)
If objRs.EOF Then
Check_PassWord = 0
Else
If password <> Trim(objRs("password")) Then
Check_PassWord = 1
Else
Check_PassWord = 2
CurrentUserName = objRs("username")
CurrentUserPassWord = objRs("password")
' CurrentUserStatus = objRs.Fields("身份").Value
End If
End If
conn.Close
Set objRs = Nothing
Set conn = Nothing
Exit Function
Check_PassWord = 255
End Function
...全文
49 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
mokton 2010-10-27

Private Function Check_PassWord() As Byte
Dim conn As New ADODB.Connection '定义ADODB连接对象
Dim rs As New ADODB.Recordset '定义数据集对象
Dim connstr As String '定义连接字符串
connstr = "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & App.Path & "\db1.mdb;" '给连接字符串赋值
conn.Open connstr '打开链接
username = Trim(username.Text) '赋值 用于查询
password = Trim(password.Text) '赋值 用于查询
strSQL = "SELECT * FROM 系统用户 WHERE username='" & username & "'" '构造SQL语句
Set objRs = conn.Execute(strSQL) '执行SQL语句
If objRs.EOF Then '如果到了数据集的结尾
Check_PassWord = 0 '赋值
Else '
If password <> Trim(objRs("password")) Then '判断呗
Check_PassWord = 1 '赋值
Else '
Check_PassWord = 2 '赋值
CurrentUserName = objRs("username") '读取数据库记录值给当前用户名
CurrentUserPassWord = objRs("password") '读取数据库记录密码值赋值给当前用户密码
' CurrentUserStatus = objRs.Fields("身份").Value
End If
End If
conn.Close '关闭数据库链接
Set objRs = Nothing '清除对象
Set conn = Nothing '清除对象
Exit Function '
Check_PassWord = 255 '
End Function
回复
ahljxwy 2010-10-27
就这些分不能逐条!
回复
panyong 2010-10-27

Private Function Check_PassWord() As Byte
Dim conn As New ADODB.Connection '定义数据库连接
Dim rs As New ADODB.Recordset '定义数据库查询
Dim connstr
connstr = "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & App.Path & "\db1.mdb;"
conn.Open connstr '连接"& App.Path & "\db1.mdb;"(程序目录下的数据库)
username = Trim(username.Text) '获取名称为username的文本输入框名称的字符 Trim 是去掉字符中的空格
password = Trim(password.Text) ’获取密码
strSQL = "SELECT * FROM 系统用户 WHERE username='" & username & "'"
Set objRs = conn.Execute(strSQL) '查询 系统用户表 WHERE username='" & username & "'"
意思是 在 系统用户表中 查询 所有符合 用户名称为 username的文本输入框 中一样的 数据
If objRs.EOF Then
Check_PassWord = 0
Else
If password <> Trim(objRs("password")) Then
Check_PassWord = 1
Else
Check_PassWord = 2
CurrentUserName = objRs("username")
CurrentUserPassWord = objRs("password")
' CurrentUserStatus = objRs.Fields("身份").Value
End If
End If
conn.Close
Set objRs = Nothing
Set conn = Nothing
Exit Function
Check_PassWord = 255
End Function

回复
相关推荐
发帖

1188

社区成员

VB 数据库(包含打印,安装,报表)
申请成为版主
帖子事件
创建了帖子
2010-10-26 09:49
社区公告
暂无公告