|
-
Jul 29th, 2000, 02:21 PM
#1
Thread Starter
Hyperactive Member
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
-
Jul 30th, 2000, 12:20 PM
#2
Guru
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.
-
Jul 30th, 2000, 01:01 PM
#3
Thread Starter
Hyperactive Member
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.
-
Jul 31st, 2000, 08:37 AM
#4
Hyperactive Member
-
Jul 31st, 2000, 10:57 PM
#5
Guru
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|