Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Loop through recordset and assign to variables?

Status
Not open for further replies.

MottoK

Technical User
Oct 18, 2006
73
GB
Hi,

Can someone show me how to do a loop so that I can assign recordset field name values to variables please (using classic ASP)?

I have a recordset called rsChecker and I want to loop through it to create the variables like I have done manually below:


varRecSet0 = rsChecker(0)
varRecSet1 = rsChecker(1)
varRecSet2 = rsChecker(2)
varRecSet3 = rsChecker(3)
varRecSet4 = rsChecker(4)
varRecSet5 = rsChecker(5)
varRecSet6 = rsChecker(6)
varRecSet7 = rsChecker(7)
varRecSet8 = rsChecker(8)
varRecSet9 = rsChecker(9)


This will allow me to just pull through the correct amount of field elements in the recordset.

Very much appreciated.
 
You really do not want to do that. It's a waist of performance basically. Why aren't you using the RS when it si needed and destroying it? Is there some reason why you need to hold the data in variables?

Perhaps if you give us a better explanation of what you are doing we can assist in a better method for getting you what you want instead of killing your memory usage

[sub]____________ signature below ______________
The worst mistake you'll ever make is to do something simply the way you know how while ignoring the way it should be done[/sub]
 
I want to use the field names (e.g. rsChecker(0) is "Agent Name") in my heading row of my results table.

But I need to check if rsChecker(0) is null or not before I do a response.write otherwise it doesn't work - so either way will do.

Many thanks.
 
Anyone?

Above I meant to put rsChecker(0).Name instead of just rsChecker(0) - to get the field name.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top