How to Use Session Level Connection
-
Hi Folks: I have about 7-8 Pages which all connect to the same database but then generate different record sets with different queries.. So i tried giving only my connection object defnition and opening the connection in global.asa file and then using it in the other asp pages as:- objCommand.activeConnection=session("objconn") OR objRS.OPEN(QUERYSTRING,objConn") but then i am told the paramters im passing are wrong.And so i dont understand how.. Can somebody tell me if im making some fundamental mistake or is it just the code that i have to go through..:-D Why Need Parking lots in Bars when Drunken Driving is Prohibited
-
Hi Folks: I have about 7-8 Pages which all connect to the same database but then generate different record sets with different queries.. So i tried giving only my connection object defnition and opening the connection in global.asa file and then using it in the other asp pages as:- objCommand.activeConnection=session("objconn") OR objRS.OPEN(QUERYSTRING,objConn") but then i am told the paramters im passing are wrong.And so i dont understand how.. Can somebody tell me if im making some fundamental mistake or is it just the code that i have to go through..:-D Why Need Parking lots in Bars when Drunken Driving is Prohibited
fundamental mistake: Placing an open connection object is about the quickest way to bring a web server to its knees. I suggest placing only the connection string in the
application
object (assuming the connection string does not change throughout the lifetime of the application) this will give you something like thus: Global.asaSub application_onstart
application("constring")="PROVIDER=SQLOLEDB;SERVER=localhost;DATABASE=pubs;uid=sa;pwd=;"
end subanASPPage.asp
...
objRS.Open QUERYSTRING,Application("constring")Or to go one step further in conserving resources:
objCon.Open Application("constring")
objRS.Open QUERYSTRING,objCon
...
objRS.Close
objCon.Close