Page 1 of 1

UniTable1.Delete;

Posted: Sat 04 Jun 2022 17:26
by vetalkw
Good afternoon!
there is a code:

Code: Select all

procedure TFormP1.StringGrid2CellDblClick(const Column: TColumn;
  const Row: Integer);
begin
    UniTable2.RecNo:=1;
    UniTable2.Delete;
    ShowMessage('record '+IntToStr(UniTable2.RecNo)+' deleted');

end;
all rows in the table are deleted from me, how do I delete only record № 1?it seemed to me that if I put the carriage on the the first line (UniTable 2.RecNo:=1;) then the current row will be deleted, but now all rows are being deleted from my table.
how do I delete only line №1?

Re: UniTable1.Delete;

Posted: Tue 07 Jun 2022 09:11
by vetalkw
decision:

Code: Select all

procedure TFormP1.StringGrid2CellDblClick(const Column: TColumn;
  const Row: Integer);
begin
    UniTable2.RecNo:=ns+1;//in another part of the code, I assign NC the line number that the user clicked on
    UniTable2.Edit;
    ShowMessage('record '+UniTable2.Fields[2].AsString+' deleted');
    UniTable2.Delete;
end;
you also need to make sure that your table has at least one column with the status "primary key".