Posted by Sumi -- July 11, 2001
HI, I have DBGrid1, DBgrid2 and a button on my form.
I have done ADO connection and data are displayed on Dbgrid1. What I want is: if I a
select a row from DBgrid1 and click the button, the selected row must be removed from
DBgrid1
and displayed on DBGrid2. All this must updated to the database too. Just say, data displayed
on DBgrid1 is from Table1 and data that will be displayed from DBGrid2 should be updated
to Table2.
I'm using Delphi 5. Maybe u can give a database example according to dbdemos
in Ms Access.
Re: webmaster Guido -- July 16, 2001
It's the same for all versions of Delphi, and also the type of the table doesn't matter
(Paradox, dBase, Access,...).
Assuming that T1 and T2 are TTable objects, both tables
are Active, and they have the same structure:
procedure TForm1.Button1Click(Sender: TObject);
var
i: integer;
begin
// Add the record to T2
T2.Append;
for i := 0 to T1.FieldCount - 1 do
FieldByName(T2.Fields[i].FieldName).Assign(T1.Fields[i]);
T2.Post;
// Delete the record from T1
T1.Delete;
end;
DelphiLand Discussion Forum
|