Board index » delphi » recno method doesn't work

recno method doesn't work

Anyone know why the following:

table1.First;
 while not table1.EOF do
 begin
Showmessage(
                              'Record '+IntToStr(Table1.RecNo)+' of '+
                                IntToStr(Table1.RecordCount));
    table1.Next;
    end;

returns -1 every time?

 

Re:recno method doesn't work


This is a copy of the reference in VCL.HLP for RecNo:

Applies to

TTable, TQuery, TStoredProc components

Declaration

property RecNo: Longint;

Description

Run-time and read-only. The RecNo property returns a record number for the
current record in the dataset. Record numbers are only available for
Paradox and dBASE tables; the concept isn't supported by most SQL servers
so a table in a SQL database always returns -1 for RecNo.

Per-Eric Jenshagen

Quote
Neil McCarthy wrote:
> Anyone know why the following:

> table1.First;
>  while not table1.EOF do
>  begin
> Showmessage(
>                               'Record '+IntToStr(Table1.RecNo)+' of '+
>                                 IntToStr(Table1.RecordCount));
>     table1.Next;
>     end;

> returns -1 every time?

Re:recno method doesn't work


Quote
>Anyone know why the following:
>table1.First;
> while not table1.EOF do
> begin
>Showmessage(
>                              'Record '+IntToStr(Table1.RecNo)+' of '+
>                                IntToStr(Table1.RecordCount));
>    table1.Next;
>    end;

>returns -1 every time?

-1 is what you get when the dataset does not support RecNo
 for instance a Paradox table with a filter applied will not support RecNo

--
Brian Bushay (TeamB)
Bbus...@DataGuidance.com

Other Threads