Trouble with SQLUpdate

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
andi_d
Posts: 8
Joined: Fri 25 Feb 2005 14:12

Trouble with SQLUpdate

Post by andi_d » Fri 25 Feb 2005 14:41

:lol:
Hi!

I'm using TMyQuery to work with database.

Now i want to update database entries using the SQLPUpdate Method.

Code i use:

With MYQuery Do
Begin
Try
SQLUpdate.Add('UPDATE Table SET Name = 'Test'
WHERE Nr =1');

ApplyUdates
except
RestoreUpdates;
Raise;
end;

CommitUpdates;
End;.......................................

I'm just a beginner.... What is wrong??? Or is there a better way??

Thank's a lot!!!!!!! :lol:

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Fri 25 Feb 2005 16:11

The easiest way is to execute the query

Code: Select all

MyQuery.SQL.Text := 'SELECT * FROM ...';
MyQuery.Open;
MyQuery.Edit;
MyQuery.Fields[].As... := ...
MyQuery.Post;
> I'm just a beginner...

Ok, SQLUpdate and ApplyUpdates unlikely will be necessary for you at the nearest time.
[/code]

andi_d
Posts: 8
Joined: Fri 25 Feb 2005 14:12

Thanks's

Post by andi_d » Fri 25 Feb 2005 16:20

Thank's a lot!!!

That sounds much more easier!!!

andi_d
Posts: 8
Joined: Fri 25 Feb 2005 14:12

But......

Post by andi_d » Fri 25 Feb 2005 17:00

How can i write the edited value back into the database??

it looks like the edited value hase ony changes lokal!!

when i do a new query to the database the old value comes again!


thank's again!!

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Wed 02 Mar 2005 07:25

Most probably, you enabled CachedUpdates := True. Set CachedUpdates := False and data will be passed to the server by Post.

Post Reply