This doesn't entirely make sense. An object instantiation is an instance of the object (the object has been created). The object tags provide that, and it seems pretty clear that those object tags indicate that the object is instanced in the scope of the session.
If you were to simply declare the object in the the onstart, then it wouldn't be instantiated until the first time it was created, but that instance would persist throughout the life of the session, and may very well live on after the session is gone.
Here's the general idea I mentioned (please excuse the code, I had to type it out of my head):
dbHelpers.inc
<%
Dim m_objConn 'This will be the global DB connection
Function CheckDBConn()
If IsNothing(m_objConn) Then
Set m_objConn = Server.CreateObject("ADODB.Connection")
m_objConn.ConnectionString = "<myconnection string>"
m_objConn.Open()
End If
End Function
Function Execute(sSQL)
CheckDBConn
Dim objRS : Set objRS = Server.CreateObject("ADODB.RecordSet")
Set objRS = m_objConn.Execute(sSQL)
Set Execute = objRS
End Function
%>
You can expand on this idea. I think in the actual version I use, I set some recordset properties and maybe do some additional error handling, but this is the general concept. I actually created a VBScript class to wrap around the db connection object so that I only need to call 1 method on that class and it does everything internally like what I have here. If I can remember later, I'll see if I can dig it up.
Peter
------------------------------------------------------
Work smarter, not harder.
|