I'm have a table with one field and I'm trying
to edit it. Multiple records can have the same
value in this field (the field is named "Name").
Am using this code:
with DM.myType do
begin
Edit;
fieldByName('Name').AsString:=edType.Text;
// Post;
UpDateRecord;
ApplyUpdates;
edType.Text:='';
end;
As long as I edit a record which is the only record
with that "Name" value it works. If I try to edit
a record which is one of several with the same
"Name" value, it fails with this exception error message
"Update failed. Found 3 records."
As you can see I have tried Post and UpdateRecord
with the same result. Can anyone help?
TIA,
Bob
Updating a record
-
swierzbicki
- Posts: 451
- Joined: Wed 19 Jan 2005 09:59
You are answering your question
:
MySQL server will returns that 3 records has been updated. MyDAC expect 1 record to be updated and not 3
To change that either :
- modify your table structure by adding an AutoIc Field , make it your primary key (best solutionin your case)
- set the MyQuery.options.StructUpdate to false
When posting Datas, MyDAC will generate a SQL query like that :I have a table with one field [...] multiple records can have the same value
Code: Select all
Update TABLENAME
Set FieldName = :FieldName
Where
Fieldname = :FieldNameTo change that either :
- modify your table structure by adding an AutoIc Field , make it your primary key (best solutionin your case)
- set the MyQuery.options.StructUpdate to false