tuniquery edit error when select 1 field

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
lao
Posts: 71
Joined: Wed 10 Dec 2008 10:56

tuniquery edit error when select 1 field

Post by lao » Thu 10 Nov 2011 13:49

unidac version 3.70.0.19
delphi 2007

Hello,
i have a table with 3 fields(field1, field2, field3)
i do
select field2 from mytable

myquery.edit;
myquery['field2'] := 'new value';
myquery.post;
i have an error: Update failed. Found x records.
and all records in mytable with old value of field2 are updated, not only current field.

if i do
select * from mytable, no problem.
any idea?

AndreyZ

Post by AndreyZ » Thu 10 Nov 2011 14:46

Hello,

To avoid such problem, you have to include Primary Key fields into your SELECT statement. In this case the UPDATE statement will use Primary Key fields and only one record will be updated. You can set the TUniTable.Debug property to True. The Debug property is used to display the exact statement that is being executed, all its parameters' values, and the type of parameters. This will help you to understand the cause of this problem. Note that to make the Debug property work, you should add the UniDacVcl unit to the uses clause of any unit in your project.

Post Reply