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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

record count

Status
Not open for further replies.

discusmania

IS-IT--Management
Oct 24, 2000
158
AP
Hello...
I've problem to count records in my table. I've try this

dim recount
objrec.movelast
recount=objrec.recordcount
objrec.movefirst

but error returns:

Microsoft OLE DB Provider for ODBC Drivers error '80040e24'
The rowset does not support fetching backwards
/hr/dbs/news.asp, line 25

Please Help
TQ
 
you don't need to retrieve all your records to get a count. try this query:

select count(*) from myTable

nick bulka

 
Thanks for the fast reply, I'm not very familiar with SQL . I've try to do the query but the problem is , I want to hold the amount of records in a variable. How to do it?
 
If you use the following variation of te query:

Code:
select count(*) as numrows from mytable

then you can get at the result using

Code:
myvar = myrecordset("numrows")

James :)

James Culshaw
jamesculshaw@active-data-solutions.co.uk
 
Just to clarify, the results of the query will be a recordset with one record, and one field, which contains the number of records.

you could also retrieve the value by getting myrecordset(0)


nick bulka

 
CalShaya,

MANY MANY THENX!!!!

,....i've been dancing around this simple solution for an hour.
I tried to declare a variable and storing the count in it,..no result trying to extract it in ASP.
I tried to use the size of a recordset in ASP but i missed certain details,...


ThenX
RuupY
 
BTW:
The original error message probably means that you have opened your recordset as Forward Only...
 
and could be solved by setting the .cursorType to something other than the default...

rs.cursorType = 3 'adOpenStatic

would work just fine.

Just for future reference, in case you need both data and .recordCount :)
penny.gif
penny.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top