Update affected more than 1 record

使用 ClientDataSet 对主从表进行操作。

在操作中Del主表,(在SQL中写存储过程,由ID字段删除子相应的子表),报 Update affected more than 1 record 错误,删除也提交不了。用了事务也报错,怪事也!

在网上找了半天,发现没有一个中文的有较答案。

不过还是找到了英文的。呵呵~!

主表与子表之间 关系 ,创建相应的关系,不报错了,删除也能提交了。呵呵~!

附上英文:

"Update affected more than 1 record" error

(Delphi 2007)
Am using a ClientDataSet to manage editing of a simple record:

EmployeeID (primary key)
FirstName (required)
LastName (required)
HireDate (required)
ExitDate (not required)
Nickname (not required)
Photo (image, not required)

Have one case where there are two records with the same employee
First/LastName but different keys and other values. Changing the value of
any field (e.g. nickname) in one of these records and calling ApplyUpdates
generates "Update affected more than 1 record". I seem to get this error no
matter what the Provider Flags are set to for the Provider and Client
DataSet (EmployeeID has pfInKey set). I don't understand because the
EmployeeID field should uniquely identify which record to change.

How we set the Provider Flags for the DataSet Provider and for the fields
doesn't seem to make any difference. Also, we've been following the same
format for all sorts of database tables previously and have not seen this
error before now.Can anyone give me a direction to go in? No luck Googling
this error and CodeGear's help is woeful.

Many thanks for your assistance.

Jeff  

 

Solved the problem:

Had a database trigger on the table that was not key specific. Updates to
the dataset where firing this trigger which caused the error.


"Bill Todd" <[email protected]> wrote in message
news:[email protected]...
> Jeff W. wrote:
>
>> Provider and Client DataSet (EmployeeID has pfInKey set). I don't
>> understand because the EmployeeID field should uniquely identify
>> which record to change.
>
> You must set the ProviderFlags on the source dataset (the one in the
> DSP's DataSet property) not the CDS.
>
> --
> Bill Todd (TeamB)

你可能感兴趣的:(update)