gdlp2004
asked on
Saving Resultset to Session or Request Scope
With the following code, and where I put my comment, I want to save this resultset to a request scope (or session). How do you do both, and how do you pull it out and iterate through it when you want to retrieve it on another page? I know in Java it is request.setAttribute("SOME THING",som ethingsVal ue); but I don't know it in ASP.
Here is my code:
Set Con = Server.CreateObject( "ADODB.Connection" )
Con.Open strConn
DIM questionSQL, questionRs
questionSQL = "SELECT quizid, difficultytype, maxnumberofquestions from quiz"
SET questionRs = con.execute(questionSQL)
' I want to save to request scope here
questionRs.close %>
</body>
</html>
Here is my code:
Set Con = Server.CreateObject( "ADODB.Connection" )
Con.Open strConn
DIM questionSQL, questionRs
questionSQL = "SELECT quizid, difficultytype, maxnumberofquestions from quiz"
SET questionRs = con.execute(questionSQL)
' I want to save to request scope here
questionRs.close %>
</body>
</html>
ASKER
How about as a request variable?
ASKER
Would it be Request("ResultSetName") = arrResultSet?
And then, to iterate through it do you do:
while Request("ResultSetName").E OF? Or do you have to save it as another variable then iterate?
And then, to iterate through it do you do:
while Request("ResultSetName").E
Saving a request variable is much better :
Session("strRequestVariabl e") = Request.Form("strNameOfVar iableYouWa ntToSave")
and then to retrieve the variable:
Response.write(Session("st rRequestVa riable"))
FtB
Session("strRequestVariabl
and then to retrieve the variable:
Response.write(Session("st
FtB
ASKER
Cool. Now that I know how to use both, can you do it without using Session at all? I mean, just save a variable to the Request object and then pull it out?
Also, say if this recordset has 5 records that I want to display, how do you iterate through it when you pull it from the Request? Is it the same as the code I last posted?
Also, say if this recordset has 5 records that I want to display, how do you iterate through it when you pull it from the Request? Is it the same as the code I last posted?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That will work. Thanks!
Glad to have helped,
FtB
FtB
If you really, really, want to do that, however, you can do something like this:
SET questionRs = con.execute(questionSQL)
arrResultSet = questionRs.GetRows()
Session("ResultSet") = arrResultSet
FtB