zoukankan      html  css  js  c++  java
  • 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" <no@no.com> wrote in message
    news:46fd9189$1@newsgroups.borland.com...
    > 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)

  • 相关阅读:
    安装MySQL ODBC应注意的问题
    AJAX跨域资源共享 CORS 详解
    RealThinClient SDK 学习笔记(1)
    mysql中两表更新时产生的奇葩问题,产生死锁!
    MySQL使用FEDERATED engine建立代理表
    Java Collection与ConcurrentModificationException
    Maven 命令
    多线程12-ManualResetEventSlim
    多线程11-AutoResetEvent
    多线程10-SemaphoreSlim
  • 原文地址:https://www.cnblogs.com/yanyyx/p/1388609.html
Copyright © 2011-2022 走看看