Click to See Complete Forum and Search --> : rs.RecordCount


hspc
March 1st, 2003, 09:48 AM
hi all
i open an access database from asp .. for some reason i need to know the number of records in the recordset before processing it as follows :


set con=Server.CreateObject("Adodb.Connection")
set rs=Server.CreateObject("Adodb.Recordset")
con.ConnectionString=strCon
con.CursorLocation=1 'server
con.Open
set rs.ActiveConnection=con
rs.CursorType=adOpenKeySet
rs.open "select * from items"
rs.MoveLast
n=rs.RecordCount
Response.Write n

i get an error :

Microsoft OLE DB Provider for ODBC Drivers (0x80040E24)
Rowset does not support fetching backward.


can you help with this ?

antares686
March 1st, 2003, 07:50 PM
Instead of

rs.CursorType=adOpenKeySet
rs.open "select * from items"


try

rs.CursorType=adOpenStatic
rs.open "select * from items"

see if it works. If others fail this usually willk do it.

hspc
March 2nd, 2003, 04:57 PM
Hi..
I changed the driver in the connection string from
Microsoft access
to:
Jet 4.0
and it worked !!