<script language="vbscript" runat="server">
'******************************
'名称:用户属性显示类
'日期:2005/12/3
'作者:西楼冷月
'网址:www.xilou.net//www.chinaCMS.org
'描述:无
'版权:转载请注名出处,作者
'
'
'******************************
'On Error Resume Next
Class UserInfo
'---------------------------------------------
'属性声明
Private SqlStr
Private ConnStr
Private GetUserInfoRs
Public UserInfo
Private IsErr
'---------------------------------------------
'---------------------------------------------
Private Sub Class_Initialize
IsErr=True'判断是否存在这个用户,不存在则为FALSE
End Sub
Private Sub Class_Terminate
If IsObject(GetUserInfoRs) Then
GetUserInfoRs.Close
Set GetUserInfoRs=Nothing
End If
If IsObject(ConnStr) Then
ConnStr.Close
Set ConnStr=Nothing
End If
End Sub
'--------------------------------------------
'--------------------------------------------
'取得SQL语句
Public Property Let GetSql(Sql)
SqlStr=Sql
End Property
Public Property Get Sql
Sql=SqlStr
End Property
'创建Conn对象
Public Property Let Conn(Obj)
Set ConnStr=Obj
End Property
'--------------------------------------------
'--------------------------------------------
Public Sub Exec()
Set GetUserInfoRs=Server.CreateObject("Adodb.RecordSet")
GetUserInfoRs.Open SqlStr,ConnStr,1,1
If GetUserInfoRs.Bof And GetUserInfoRs.Eof Then
IsErr=False'判断是否存在这个用户,不存在则为FALSE
'Exit Sub
Else
Dim I,Str
Do While Not GetUserInfoRs.Eof
For I=0 To GetUserInfoRs.Fields.Count-1
Str=Str&"|"&GetUserInfoRs(I)
Next
GetUserInfoRs.MoveNext
Loop
End If
Str=IsErr&Str
UserInfo=Split(Str,"|")
End Sub
End Class
'-------------------------------------------------------------------
'示例:
Dim ConnStr
ConnStr="Provider=Microsoft.Jet.Oledb.4.0;Data Source="&Server.MapPath(DataDir)
Set Conn=Server.CreateObject("Adodb.Connection")
Conn.Open ConnStr
Set SysTem=New UserInfo'类实例
System.Conn=Conn '数据库连接对象
System.GetSql="SELECT * FROM BBS_User Where UserID=1" 'SQL执行语句
System.Exec '执行
For i=LBound(System.UserInfo) To UBound(System.UserInfo)
Response.Write System.UserInfo(i)&"<br>" '循环读出信息
Next
Set SysTem=Nothing
</script>