-
Hi all,
-------------------------------------
The code in my global.asa file is as follows
<SCRIPT LANGUAGE=VBSCRIPT RUNAT=SERVER>
Sub Session_OnStart
Set Session("Cnn") = Server.CreateObject("ADODB.Connection")
Session("Cnn").Provider="Microsoft.Jet.OLEDB.4.0"
Session("Cnn").Open "C:\Inetpub\wwwroot\Test.mdb"
End Sub
Sub Session_OnEnd
Session("Cnn").Close
End Sub
</SCRIPT>
---------------------------------------
I have created an ActiveX DLL which uses Microsoft Active Server Pages Object Library
The code in its class file is as follows.
Private ASPResponse As Response
Private ASPSession As Session
Public Sub OnStartPage(sc As ScriptingContext)
Set ASPResponse = sc.Response
Set ASPSession = sc.Session
End Sub
Public Sub PleaseRetrieve()
Dim rs As New ADODB.Recordset
rs.Open "Select * FROM ABCD", ASPSession("Cnn"), adOpenKeyset, adLockOptimistic, adCmdText
'It gives me an error in the above statement. The error message is Run-time error 3001: the application is using arguments that are of the wrong type.
'The error is being caused due to the argument ASPSession("Cnn") which is actually valid as it is being created in the global.asa script
End Sub
----------------
Thanks in advance
-
You are storing a connection object in the session variable? You are a BAD BAD BAD BAD BAD boy
Seriously though, don't do this for performance reasons. MTS and/or IIS will pool your database connections, so all of your DLL functions should explictly create a connection object, do its work, then destroy the connection.
-
Thanks a lot Clunietp. But then when should one be using these session and application variables. Also any info source for the do's and dont's in ASP.
-
-
Use session & application variables sparingly, as they eat up memory. I never use session or application variables anymore, I usually use querystrings or hidden form variables, and keep as much state as possible on the client using cookies