Problems with MyQuery and UPDATE

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
EdderU2RSE
Posts: 10
Joined: Tue 17 Apr 2007 19:47

Problems with MyQuery and UPDATE

Post by EdderU2RSE » Wed 25 Apr 2007 13:41

Hello, I have a Myquery(called Query Update) component, and need to update a field in my Table. The code in myquery is:
UPDATE productos // Table
SET stock=stock // stock is a parameter
WHERE codigo=codigo // codigo ia a parameter

Stock and Codigo are written in 2 DBedits to modify te table.

Later, I have a Button to execute mi code:
QueryUpdate.Close;
QueryUpdate.SQL.Clear;
QueryUpdate.SQL.Text:=('UPDATE productos SET stock='+txtstock.Text);
QueryUpdate.SQL.Text:=('WHERE codigo='+DBstock.Text);
Showmessage(Queryupdate.SQL.Text);
MyTable1.Refresh;
QueryUpdate.Open;

But, I have a mistake, because mi code, does't change the information that corresponds.

I think that have problems with myquery.

Ps. Thank you, and sorry for mi english

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Wed 25 Apr 2007 14:06

In order to execute commands that do not return result sets (INSERT, UPDATE, DELETE, etc.), you should call the TMyQuery.Execute instead of TMyQuery.Open.

Turn on the debug mode for QueryUpdate (add MyDACVCL unit to the uses clause and set the QueryUpdate.Debug property to True) and check what query is sent to the server.

EdderU2RSE
Posts: 10
Joined: Tue 17 Apr 2007 19:47

Ok thaks

Post by EdderU2RSE » Wed 25 Apr 2007 18:29

Thaks for help me.

My problem was solve susscefully

PS Thaks
sorry for mi english

Post Reply