Sesond insert doesn't work

Sesond insert doesn't work

Postby wolfben » Tue 28 Feb 2006 13:05

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
wolfben
 

Postby Antaeus » Tue 28 Feb 2006 14:12

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;
Antaeus
 
Posts: 2098
Joined: Tue 14 Feb 2006 10:14


Return to MySQL Data Access Components