Board index » delphi » Retrieving TDataSet Current Record Number

Retrieving TDataSet Current Record Number

I am looking for a way to obtain the current record number from a TTable
or TQuery component displayed in a TDBGrid. It seems to me that this
should be very simple but I continue to get -1 as the online help tells
me I will. The help says the following:

*****
This function returns -1 in all cases. Ordinarily an application will
not access RecNo at the TDataSet level. Instead a redeclared and
implemented RecNo property in a descendant object such as TTable is
accessed. RecNo provides a fallback property for derived dataset objects
that do not reimplement it.
*****

Can anyone tell me how to reimplement it or otherwise get the current
record number? Thanks in advance for your help!

Kevin

 

Re:Retrieving TDataSet Current Record Number


Try RecordCount.

Re:Retrieving TDataSet Current Record Number


Kevin,

SQL databases don't support record numbers.  You can "simulate" a record
number in some systems by using special functions (SQL Anywhere for
example: 'SELECT Number(*), * FROM TableName').  I've heard of folks
using a calculated AutoInc field but have never tried it myself.  You'd
have to research your backend system to see what, if anything, it
supports.

HTH - Mike

Quote
Kevin Meyers wrote:

> I am looking for a way to obtain the current record number from a TTable
> or TQuery component displayed in a TDBGrid. It seems to me that this
> should be very simple but I continue to get -1 as the online help tells
> me I will. The help says the following:

> *****
> This function returns -1 in all cases. Ordinarily an application will
> not access RecNo at the TDataSet level. Instead a redeclared and
> implemented RecNo property in a descendant object such as TTable is
> accessed. RecNo provides a fallback property for derived dataset objects
> that do not reimplement it.
> *****

> Can anyone tell me how to reimplement it or otherwise get the current
> record number? Thanks in advance for your help!

> Kevin

Other Threads