OK, I am new to classes and I am trying to implement a standard query that we will use on many pages that will get standard user info. I will always have a staffid to pass in and I have the sql, I am just not sure of the syntax. So, here is my first crack at it
And then I was calling it by
I know that I am missing pieces here, but not sure how to get here. Is my class setup correctly? If so, then how do I pull out specific data pieces in my pages? If not, can you help me with the class piece first?
Thanks!
wb
Code:
Class UserInfoClass
Private m_userinfo
Public Sub Class_Initialize()
Set m_userinfo = Server.CreateObject("Scripting.Dictionary")
End Sub
Public Property Get UserInfo()
Set UserInfo = m_userinfo
End Property
Public Property Set UserInfo(value)
set m_userinfo = value
End Property
End Class
function GetUserInfo(staffID)
Dim conn, sqltext
Dim userinfo : Set userinfo = Server.CreateObject("Scripting.Dictionary")
Set conn=Server.CreateObject("ADODB.Recordset")
sqltext = "SELECT s.SiteID, SiteName, s.SiteURL, st.FirstName, st.LastName, st.Email " &_
"FROM NewCompass.dbo.tblSite s " &_
"join NewCompass.dbo.tblStaffProtocol sp on s.SiteID=sp.SiteID " &_
"join NewCompass.dbo.tblStaff st on st.StaffID=sp.StaffID "&_
"WHERE st.StaffID='"& session("sessionUserID")&"' " &_
"and ProtocolID=0 and ProjectID=3"
conn.Open sqltext, strNewCompass
userinfo.add "siteid",conn("siteid")
userinfo.add "SiteName",conn("SiteName")
userinfo.add "SiteURL",conn("SiteURL")
userinfo.add "FirstName",conn("FirstName")
userinfo.add "LastName",conn("LastName")
userinfo.add "Email",conn("Email")
Set GetUserInfo = userinfo
conn.Close
set conn=nothing
end function
And then I was calling it by
Code:
Dim oUserInfoClass : Set oUserInfoClass = New UserInfoClass
Set oUserInfoClass.UserInfo = GetUserInfo(session("sessionuserid"))
dim siteid : siteid = ouserinfoclass.item("siteid")
response.write siteid
I know that I am missing pieces here, but not sure how to get here. Is my class setup correctly? If so, then how do I pull out specific data pieces in my pages? If not, can you help me with the class piece first?
Thanks!
wb