index > .NET Framework Data Access and Storage > Geting Total Number of Rows in a Recordset

Geting Total Number of Rows in a Recordset

Hello,

how do i get the total number of rows in a recordset.

when i use the RecordCount, gives me -1

like:

vCount = rstMaster.RecordCount

returns -1 WHY ?????




ferror
ferror

ADO.NET will return -1 if it cannot determine the number of records or if the provider or cursor does not support RecordCount property.

Thread moved to the appropriate forum




Need 2 be back @ MS - MS All the way! Follower since 1995 MS Super Evangelist| MSDN Forums Moderator
ahmedilyas

Hi,

I'm guessing you're using plain ADO (e.g. with VB6), not ADO.NET (as in .NET framework)?

If it is ADO, you're probably using server-side cursor. Use client cursor instead or loop through whole recordset (or .MoveLast) to get the count.

Andrej

Andrej Tozon

To be able to get an actual record count in ADO recordset, you need to open it on client side. In this case provider will return actual count. Otherwise provider is not able to determine it and will return -1.

This topic is not related to ADO.NET and will be locked and deleted later on




Val Mazur (MVP) http://xport.mvps.org
VMazur
reply 4

You can use google to search for other answers

 

More Articles

• There is already an open DataReader associated with this Command ...
• SqlRowsCopied event in SqlBulkCopy + .NET 2.0
• Returning Exceptions with ExecuteScaler from RAISERROR in a SQL P...
• DataView with DateTime comparation
• Framework Versions
• Warehouse Managment System
• SQLExpress - SQLDataAdapter Conflict
• Help with MS Access SQL Query
• DataGridView Detail Row Saving
• Selecting / Update records - Concurrancy
Bookmark and Share
Welcome to Bokebb   New Update  
 

New Articles

• multiple to single - oracle help req.
• Interesting behavior causing: "Ther
• How to create a script for creation of u
• default value 0
• How to Insert the records from DBF into
• Error when importing an Excel SS into a
• Problem with TableAdapter Updating Datab
• The provider could not determine the Dec
• Same Problems
• mapping issue with sql executenonquery m
• is it possible to interrupt fill method
• mapping issue in ado.net when executeNon
• Automatic Designer Replacement of 'local
• Problem getting schema information: Allo
• transaction problem

Hot Articles

• Embarrassing Problem with inserting reco
• Import Excel sheet using ASP.net web app
• Using classic ADO parameter objects from
• DataSet or DataReader
• Access Excel File On Different Server **
• SQL server 2005 data base with visual st
• database diagram node in server explorer
• problems in Executing stored procedures
• Obtain dimension in byte of a record
• Update Excel Data
• Iframe & SqlDataSource
• how to read only certain fields(columns)
• SQL Server Procedure call timeout from .
• DataGridView vs DataGrid vs VB6 DataGrid
• Help with queries

Recommend Articles

• Enterprise Library for .NET Framework 2.
• ms exchange alldayevent error
• Saving a Blob file into SQL Server with
• ASP.Net worker process can't accessing O
• delete row is not updating in dataAdapter
• How to import data from another database
• Iframe & SqlDataSource
• help: I need to view all the tables in a
• What is the List<OdbcParameter>.En
• convert database to xml
• VB.NET Front end for small amount of XML
• If for my web app, I set max connection
• Using DataSet to create database
• You help will be appreciated: Connection
• Mapping Xsd element attributes to DataSet