PDA

View Full Version : RecordSet


Abd
10-04-2002, 06:23 PM
Hi All,

I am selecting some records into a RecordSet from a Database using;

RS.Open "select name,age,address from toy where name = '" &firstname& "'", Con
BnchCD = RS.Fields("name")

please how can I send the variable that stores the value to another page before using ;

<input name="acct" type="text"value="<%=Server.HTMLEncode(BnchCD)%>" >

to populate the textbox?

Thanks

Abd

BigDaddy
10-04-2002, 09:22 PM
Why not just execute the query first thing on the next page?

fractalvibes
10-04-2002, 10:39 PM
DO something like:
qs = "nextpage.asp?Branch=" & BnchCD
Response.Redirect qs

OR
you could always set a session variable
Session("Branch") = BnchCD
and access in page 2:
brnch = Session("Branch")

Phil J.

whammy
10-05-2002, 12:26 AM
Yeah, if you're not concerned about the variable being passed in the querystring, that's probably the easiest way to do it.

That having been said, you usually want to put some safeguards in the page so if someone tries to access the page directly without a querystring (or the wrong one), they don't receive an error... i.e.:


'****************************** REQUEST VARIABLES
sid = Request.QueryString("sid")
If sid = "" Then Response.Redirect("displayscript.asp?sid=0")


In addition, you may also want to put the same kind of redirect after you see if the recordset object in the query you run is EOF (End Of File) - if not, display your page... otherwise close the connection you opened (to save on server resources) and redirect.

The above is a working example from my current website redesign...

P.S. BigDaddy in my opinion you should usually avoid making additional queries to the server when it's unnecessary (such as if you are only passing 1 or 2 values to a page), just to save on server resources... they all add up.

;)