Returning the Number of records in a recordset 
Author Message
 Returning the Number of records in a recordset

I have tried using recordcount but i always returnes -1.  I there there
another way to do it besides a loop.


Sat, 21 Sep 2002 03:00:00 GMT  
 Returning the Number of records in a recordset
You can't use the RecordCount property with a forward only cursor for the
recordset in a SQL server Db.
You need to open the recordset with a richer cursor.  For example:

someSQL = "SELECT * FROM atable"
Set dataConn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")
dataConn.Open "DSN=somedsn"
rs.CursorType = adOpenDynamic
rs.Open someSQL, dataConn
strCount = rs.recordcount
Response.write "The total number of records are " & strCount & "."

--
Rick



Quote:
> I have tried using recordcount but i always returnes -1.  I there there
> another way to do it besides a loop.



Sat, 21 Sep 2002 03:00:00 GMT  
 Returning the Number of records in a recordset
Of course if you open the recordset with a dynamic cursor, the record count
can be changing...

S

Quote:
> You can't use the RecordCount property with a forward only cursor for the
> recordset in a SQL server Db.
> You need to open the recordset with a richer cursor.  For example:

> someSQL = "SELECT * FROM atable"
> Set dataConn = Server.CreateObject("ADODB.Connection")
> Set rs = Server.CreateObject("ADODB.Recordset")
> dataConn.Open "DSN=somedsn"
> rs.CursorType = adOpenDynamic
> rs.Open someSQL, dataConn
> strCount = rs.recordcount
> Response.write "The total number of records are " & strCount & "."

> --
> Rick




> > I have tried using recordcount but i always returnes -1.  I there there
> > another way to do it besides a loop.



Sat, 21 Sep 2002 03:00:00 GMT  
 Returning the Number of records in a recordset
I've found that a static cursor (adOpenStatic) usually gives me a value in
the RecordCount property.

--
Matt J. Crouch
Centillion Digital Systems, Inc.
Author of "Web Programming with ASP and COM", Addison Wesley, ISBN:
0201604604


Quote:
> Of course if you open the recordset with a dynamic cursor, the record
count
> can be changing...

> S


> > You can't use the RecordCount property with a forward only cursor for
the
> > recordset in a SQL server Db.
> > You need to open the recordset with a richer cursor.  For example:

> > someSQL = "SELECT * FROM atable"
> > Set dataConn = Server.CreateObject("ADODB.Connection")
> > Set rs = Server.CreateObject("ADODB.Recordset")
> > dataConn.Open "DSN=somedsn"
> > rs.CursorType = adOpenDynamic
> > rs.Open someSQL, dataConn
> > strCount = rs.recordcount
> > Response.write "The total number of records are " & strCount & "."

> > --
> > Rick




> > > I have tried using recordcount but i always returnes -1.  I there
there
> > > another way to do it besides a loop.



Sun, 22 Sep 2002 03:00:00 GMT  
 Returning the Number of records in a recordset
Try this URL:

http://www.15seconds.com/search/goto.asp?Goto=http%3A%2F%2Fwww%2E4guy...
lla%2Ecom%2Fwebtech%2Fcommondberrors%2Eshtml


Quote:
> I have tried using recordcount but i always returnes -1.  I there there
> another way to do it besides a loop.



Sun, 22 Sep 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Return the Number of Records in a Recordset

2. Record number in recordset

3. Record number in recordset

4. Number of records in recordset ?

5. returning the number of records affected using ado execute method

6. Returning a random number of DB records

7. ASP: Number of records returned

8. Returning the number of records = to an entered value

9. return number of records in a select query

10. Return EXACTLY N number of Records ??

11. Different Number of Returned Records

12. Report returns incomplete number of records

 

 
Powered by phpBB® Forum Software