Page 1 of 1

Trouble with SQLUpdate

Posted: Fri 25 Feb 2005 14:41
by andi_d
: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:

Posted: Fri 25 Feb 2005 16:11
by Ikar
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]

Thanks's

Posted: Fri 25 Feb 2005 16:20
by andi_d
Thank's a lot!!!

That sounds much more easier!!!

But......

Posted: Fri 25 Feb 2005 17:00
by andi_d
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!!

Posted: Wed 02 Mar 2005 07:25
by Ikar
Most probably, you enabled CachedUpdates := True. Set CachedUpdates := False and data will be passed to the server by Post.