Page 1 of 1

Sesond insert doesn't work

Posted: Tue 28 Feb 2006 13:05
by wolfben
Hi there,

I'm new to myDac and just got the first problem:
I'm using "MyCommand" for inserting data into a table.

I got a button where you can make an insert.
The first insert works, the second gives an SQL-Syntax(#42000) error.

I don't understand this because the statement doesn't change.

Here's the proc.:

Code: Select all

procedure Tfrm_main.Button1Click(Sender: TObject);
begin
  MyCommand1.SQL.Add('INSERT INTO tbl_test (test) VALUES ('+QuotedStr('test')+')');
  MyCommand1.Execute();
end;

Thx,
ben

Posted: Tue 28 Feb 2006 14:12
by Antaeus
The INSERT statement is duplicated in SQL property after second button click. Try to change your code to:

Code: Select all

procedure Tfrm_main.Button1Click(Sender: TObject); 
begin 
  MyCommand1.SQL.Clear;
  MyCommand1.SQL.Add('INSERT INTO tbl_test (test) VALUES ('+QuotedStr('test')+')'); 
  MyCommand1.Execute(); 
end;