The problem with TADOCommand in Delphi?

When you first run the current code it's all right, if you reuse error - no parameter G1.

ADOCommand1.CommandText := 'delete from [Test] where GUID = :G1';
ADOCommand1.ParamCheck := False;
ADOCommand1.Parameters.ParamByName('G1').Value := guid;
ADOCommand1.Execute();

What could be the problem?

Upd(!): more precisely, the problem happens if you use a ADOCommand1 for the other team, and then try again to use the current.
July 9th 19 at 13:30
1 answer
July 9th 19 at 13:32
Solution
In ADOCommand left the parameters from the previous command, and from new no.

If ADOCommand1 created dynamically, you have to do:

ADOCommand1.CommandText := 'delete from [Test] where GUID = :G1';
ADOCommand1.Parameters.Clear;
ADOCommand1.Parameters.ParseSQL(ADOCommand1.CommandText, True);
ADOCommand1.Parameters.ParamByName('G1').Value := guid;
ADOCommand1.Execute();


If ADOCommand1 lies on the form, each team must put on the shape of a single TADOCommand.
Now writes an error: Incorrect syntax near the construction ":" - Zachary_Botsford40 commented on July 9th 19 at 13:35
Understood - it was just not to miss a single command, then it works. - Zachary_Botsford40 commented on July 9th 19 at 13:38

Find more questions by tags Delphi