Click to See Complete Forum and Search --> : Set variable to record from database?
Is it possible to put the number of records returned by an SQL query into an ASP variable, if so how?!
Thanks,
IxxI
EDIT: Sorry about the wrong title - I was typing in the wrong window :o
minority
08-03-2005, 07:18 AM
yessimply count the number of records what ever way you like to do it there are several.
if you do it the followin way with a while statment then do the following.
<%
i = 0
Do While not rsncr.EOF
rsncr("field_Name")
i = i + 1
rsncr.MoveNext
Loop
rsncr.Close
Set rsncr = Nothing
response.write(i)
%>
This will increment i for each loop that is required then print out the number of records.
or you could do it with an sql statement.
<%sql - SELECT COUNT(ColumnName) FROM table%>
You can also put a where statement in the above so it only counts the records that you want.
buntine
08-03-2005, 09:11 AM
It would be slightly more efficient to use the RecordCount property or the RecordSet object rather than via a loop. Note, it is not available to all cursor types.
Regards.