Page 1 of 1

Insert into

Posted: Mon 11 Feb 2008 14:48
by ibdac2pro
Hi i'm new to SQL.
I have a problem with insert into.
I have simplified the problem as follows

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
with query1 do
begin
text:='INSERT INTO TEST3 ( NAME) VALUES (:NAME)';
query1.Prepare;
query1.Params[0].AsString:=edit1.Text;
query1.Execute;
query1.unPrepare;
end;
ibctable1.Refresh;
end;

Query1 is an IBCSQL1


Why can I get the table to show records being entered. But after you close the app, the table is empty.

TEST3 uses a gen field in interbase for TEST_NO (Not Shown)

Posted: Tue 12 Feb 2008 15:17
by Plash
You do not commit changes made to the table. To do this:
- set AutoCommit property in all components you use (TIBCConnection, TIBCSQL) to True;
- or call TIBCSQL.Transaction.CommitRetaining after TIBCSQL.Execute to make all changes to the table permanent and retain data in TIBCTable component.