Trouble with SQLUpdate

Trouble with SQLUpdate

Postby 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:
andi_d
 
Posts: 8
Joined: Fri 25 Feb 2005 14:12

Postby 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]
Ikar
 
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Thanks's

Postby 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......

Postby 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!!
andi_d
 
Posts: 8
Joined: Fri 25 Feb 2005 14:12

Postby 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.
Ikar
 
Posts: 1693
Joined: Thu 28 Oct 2004 13:56


Return to MySQL Data Access Components