主题:高手请进!!!
首先,谢谢你来看鄙人的贴,既然来了请留名!
下面的一段代码换成通过Access来打开记录集!(不知道表达清楚没?)
strCurrentUserName strCurrentUserPassword strCurrentUserStatus 已在模块中声明
Private Function check_password() As Byte
On Error GoTo gperror
Dim objcn As New Connection
Dim objrs As New Recordset
Dim strCn As String, strsql As String
'建立数据库连接
strCn = "Provider=MSDASQL.1;Persist Security Info=false;" & "data source= 物管数据DSN"
objcn.ConnectionString = strCn
objcn.ConnectionTimeout = 30
objcn.Open
'执行查询命令,获得用户登录口令
strsql = "select*from 系统用户 Where 用户名=" '&txtlog(0)&'""
Set objrs.ActiveConnection = objcn
objrs.Open (strsql)
If objrs.EOF Then
check_password = 0 '没有查询结果,表示该用户为非法用户
Else
If txtlog(1) <> Trim(objrs.Fields("口令")) Then
check_password = 1 '口令不正确
Else
check_password = 2 '口令正确
'保存用户信息
strCurrentUserName = objrs.Fields("用户名")
strCurrentUserPassword = objrs.Fields("口令")
strCurrentUserStatus = objrs.Fields("身份")
End If
End If
'关闭数据库连接,释放对象
objcn.Close
Set objrs = Nothing
Set objcn = Nothing
Exit Function
gperror:
check_password = 225
End Function
下面的一段代码换成通过Access来打开记录集!(不知道表达清楚没?)
strCurrentUserName strCurrentUserPassword strCurrentUserStatus 已在模块中声明
Private Function check_password() As Byte
On Error GoTo gperror
Dim objcn As New Connection
Dim objrs As New Recordset
Dim strCn As String, strsql As String
'建立数据库连接
strCn = "Provider=MSDASQL.1;Persist Security Info=false;" & "data source= 物管数据DSN"
objcn.ConnectionString = strCn
objcn.ConnectionTimeout = 30
objcn.Open
'执行查询命令,获得用户登录口令
strsql = "select*from 系统用户 Where 用户名=" '&txtlog(0)&'""
Set objrs.ActiveConnection = objcn
objrs.Open (strsql)
If objrs.EOF Then
check_password = 0 '没有查询结果,表示该用户为非法用户
Else
If txtlog(1) <> Trim(objrs.Fields("口令")) Then
check_password = 1 '口令不正确
Else
check_password = 2 '口令正确
'保存用户信息
strCurrentUserName = objrs.Fields("用户名")
strCurrentUserPassword = objrs.Fields("口令")
strCurrentUserStatus = objrs.Fields("身份")
End If
End If
'关闭数据库连接,释放对象
objcn.Close
Set objrs = Nothing
Set objcn = Nothing
Exit Function
gperror:
check_password = 225
End Function