Efficient Code...

mcsd_me
08-05-2002, 11:56 AM
On an ASP page which would be the better use of creating the DLL?

Creating it and destroying it inside each function call(as below) or to create it at the TOP of the page and essentially SHARE it?

Thanks



:--------------------------------------------------------------------------------
'##################################################################### ##############################
#

function GetUsers(byval intChatid)

set Chat = server.CreateObject ("Chat.Utilities")
set GetUsers = Chat.RunSPReturnRS(CONNECTION_STRING, "db_GetUsers", _
Array(Array("id", adInteger, adParamInput, 4, intChatid)), Null)
set Chat = nothing

end function

'##################################################################### ##############################
#

function GetUserRole(byval intUserId, byval intChatRoomID)

set Chat = server.CreateObject ("Chat.Utilities")
set GetUserRole = Chat.RunSPReturnRS(CONNECTION_STRING, "db_GetUserRole", _
Array(Array("ChatRoomID", adInteger, adParamInput, 4, intChatRoomID), _
Array("UserID", adInteger, adParamInput, 4, intUserId)), Null)
set Chat = nothing

end function

'##################################################################### ##############################
#

function SetUserActivity(byval intUserId, byval intActivityStatus)
' intActivityStatus 1 = Active
' intActivityStatus 0 = InActive
set Chat = server.CreateObject ("Chat.Utilities")
Call Chat.RunSP(CONNECTION_STRING, "db_SetUserActivity", _
Array(Array("id", adInteger, adParamInput, 4, intUserId), _
Array("isActive", adInteger, adParamInput, 5, intActivityStatus)), Null)
set Chat = nothing

end function

Rezner
08-05-2002, 01:14 PM
Try setting the .dll with an application level variable in the global.asa file's Application_OnStart event with something like this:sub Application_OnStart
Set Application("Chat") = Server.CreateObject ("Chat.Utilities")
end sub

sub Application_OnEnd
Set Application("Chat") = Nothing
end subThen, instead of referencing Chat, you'd reference application("Chat").

mcsd_me
08-05-2002, 01:18 PM
IS that REALLY efficient cause I will have hundreds of chatters hitting the server in a short amount of time.

Rezner
08-07-2002, 08:37 PM
Originally posted by mcsd_me
IS that REALLY efficient cause I will have hundreds of chatters hitting the server in a short amount of time. Well, i don't know the specifics of that object but, yes, it could very well be much more efficient. Here's what you may be able to do:
set GetUsers = Application("Chat").RunSPReturnRS(CONNECTION_STRING, "db_GetUsers", _
Array(Array("id", adInteger, adParamInput, 4, intChatid)), Null)That way, only one instance of "Chat" is created and all 500 users may be able to use it.

mcsd_me
08-08-2002, 06:39 AM
Originally posted by Rezner
Well, i don't know the specifics of that object but, yes, it could very well be much more efficient. Here's what you may be able to do:
set GetUsers = Application("Chat").RunSPReturnRS(CONNECTION_STRING, "db_GetUsers", _
Array(Array("id", adInteger, adParamInput, 4, intChatid)), Null)That way, only one instance of "Chat" is created and all 500 users may be able to use it.

I am using it the way suggested and it seems to work ok. I will only really know if it is scalable in a couple of weeks when 30 users hammer on the chat room.

Thanks

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum