ado recordset.recordcount has value 0

ado recordset.recordcount has value 0

Post by cGhlcm1 » Wed, 25 Feb 2004 19:56:05


I have this really weird problem
When I query a database with a string, which I know will return only one record, by using an asp page, the recordcount object of the adodb.recordset has value 0. I do know that the sql query I use is ok, because I tested it in my database app

I use Windows 2003 server as the asp platform and I use mysql 4.0.18 ad the database

Please can anyone help me? It's dirving me crazy!
 
 
 

ado recordset.recordcount has value 0

Post by Victor Koc » Thu, 26 Feb 2004 00:27:06

Hi pherms, i believe is better use BOF and EOF properties to know if a
recordset have records.

Rs.Open "SELECT ................"

If Rs.BOF = False And Rs.EOF = False Then
' Recordset have records
else
' Recordset don't have records
endif

RecordCount Property is not supported for all providers.


"pherms" < XXXX@XXXXX.COM > escribien el mensaje
>> I have this really weird problem. >> When I query a database with a string, which I know will return only one
record, by using an asp page, the recordcount object of the adodb.recordset
has value 0. I do know that the sql query I use is ok, because I tested it
in my database app. >> >> I use Windows 2003 server as the asp platform and I use mysql 4.0.18 ad
the database. >> >> Please can anyone help me? It's dirving me crazy!

 
 
 

ado recordset.recordcount has value 0

Post by Paul Baker » Thu, 26 Feb 2004 00:52:45

Yes, it is better to use BOF and EOF. Using the RecordCount property forces
it to count how many records there is, which is very inefficient and could
take a long time. This could bog down your server or no good reason. You
don't care how many records there are, you just care if the RecordSet is
empty. It is also true that some providers don't support it.

The code below doesn't work if you have records and you're already at the
BOF or EOF. For example, you repeatedly go to the next record until EOF. In
this situation, BOF is False and EOF is True. The condition in the If
statement is False and so it executes the else clause "Recorset don't have
records", but actually the RecordSet does have records.

Code that functions in all situations and is slightly cleaner is:

If rs.BOF and rs.EOF Then
' RecordSet is empty
Else
' RecordSet is not empty
End If

Paul

"Victor Koch" <v i c t o r (arroba)correo(punto)waldbott(punto)com(punto)ar>

>>>> I have this really weird problem. >>>> When I query a database with a string, which I know will return only one >> record, by using an asp page, the recordcount object of the
adodb.recordset >> has value 0. I do know that the sql query I use is ok, because I tested it >> in my database app. >>>> >>>> I use Windows 2003 server as the asp platform and I use mysql 4.0.18 ad >> the database. >>>> >>>> Please can anyone help me? It's dirving me crazy! >> >>