0

This is taking around a second for each iteration. The Bookmarked rows may not be contiguous, so is there a better way to do this?

ArrYN : Array[Boolean] of String = ('0','1');

procedure TForm1.MarkDone(aYN : Boolean);
var
  sqlStr : String;
begin
  sqlStr:=
    ' UPDATE tMaster SET allDone = '+ArrYN[aYN]+
    ' WHERE anID = '+dbMain.FieldByName('anID').AsString+';';
  dbMain.SQL.Text:=sqlStr;
  dbMain.ExecSQL;
end;


for i:=0 to dbgMaster.SelectedRows.Count-1 do
begin
  dbMain.GotoBookmark(pointer(dbgMaster.SelectedRows.Items[i]));
  MarkDone(aYes);
end;
LinuxFerLife
  • 199
  • 7
  • First of all please use parametrized query instead of concatenating SQL string to avoid SQL Injection attacks. – Lukasz Szozda Aug 06 '17 at 18:42
  • @lad2025: Ahhh, assumptions, wonderful stuff. This is for my own use and for an "injection," the miscreant would need to get past seven dogs, a maid and most fearful of all, the wife. Not everyone programs for the mainstream. I am sure you suggest good-practice, but the extra work-overhead cannot be justified in this instance. – LinuxFerLife Aug 07 '17 at 14:41

0 Answers0