#1 2016-03-22 17:34:02

mmbk
Member
Registered: 2015-07-06
Posts: 9

wrong value in the TSQLRecord.FillCurrentRow property

I have this code that fills a StringGrid with the list of users

u := TSQLAuthUser.CreateAndFillPrepare(Controlador.Database, TInt64DynArray(ids));
  stringgrid1.RowCount := u.FillTable.RowCount;

  while u.FillOne do
  begin                             
    sgUsuarios.Cells[0, u.FillCurrentRow - 2] := IntToString(u.id);
    sgUsuarios.Cells[1, u.FillCurrentRow - 2] := u.LogonName;
  end;


This code works well, but I think I should use "u.FillCurrentRow - 1".

The constructor TSQLAuthUser.CreateAndFillPrepare set FillCurrentRow to 1, but when I call u.FillOne the FillCurrentRow is incremented.

source code:

function TSQLRecord.FillOne: boolean;
begin
  if (self=nil) or (fFill=nil) or (fFill.Table=nil) or
     (fFill.Table.fRowCount=0) or // also check if FillTable is emtpy
     (cardinal(fFill.FillCurrentRow)>cardinal(fFill.Table.fRowCount)) then
    result := false else begin
    FillRow(fFill.FillCurrentRow);
    inc(fFill.fFillCurrentRow);
    result := true;
  end;
end;

Is that correct?

Offline

#2 2016-03-22 19:51:16

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,666
Website

Re: wrong value in the TSQLRecord.FillCurrentRow property

This is as documented.
But naming is indeed confusing.
It stores the next row number which would be filled, not the current row number.

Offline

Board footer

Powered by FluxBB