//flex table opened by JP

Click to See Complete Forum and Search --> : Stupid ASP Problem - Why does this happen???


NURV89
11-27-2001, 09:36 PM
Ok, so I'm writing a script for a website and querying a database. I get the recordset object then i try to determine the number of records in the recordset object using "oRS.RecordCount" and it returns "-1", which as documented my Microsoft means it cannot be found...
Microsoft does not give any other way of determining this value. This seems like such a STUPID problem. Why cant oRS.RecordCount "not determine" the number of records??? Is there any way of doing this??


Thanks a lot, I'll be glad when this is all over,
Ben

qball
11-27-2001, 10:06 PM
without a code snippet, tough to tell.

Most likely you have a SQL error for your RecordSet, can you run the SQL against the DB fine? Meaning do you have a valid SQL statement that returns a result? Iffin you have SQL that returns no rows, you should get an empty RS, count=0.

Also, regardless of "oRS.RecordCount", try looping through the RS (when finished, you will have count...), iffin it does not exist, then this will fail.

Check the SQL...

Michigander
12-03-2001, 08:37 PM
I used to get this problem once in awhile
It usually referred to one of the types of recordsets, or one of the options can't remember exactly

but when you put in your RSobject I believe it is type or source or something, but one of them can have a value of adUseServer or adUseClient .... play around with the different settings and it'll help.

Redjakk
12-03-2001, 09:04 PM
Check your cursor type.

Forward only is the default and you can't do a recordcount with forward only cursor type.

If you just need the count and not the data use the SQL COUNT command and save some processing.

Looping through the recordset is slow but works. Changing the cursor type is probably the easiest.

There are are thousands of good ASP resources on the net, you shouldn't have trouble finding info on recordsets.

Try this

objRecordset.CursorType = 1

http://www.w3schools.com/ado/prop_rs_cursortype.asp

Michigander
12-03-2001, 09:14 PM
Ahhh yes!

Thank you, that was driving me nuts I couldnt' remember which property it was :)