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)

  • 相关阅读:
    讨论: 在WebControl中的Button,同时有onClientClick和onclick事件,验证控件实效
    在DropDownList中显示树形结构
    我的软件开场白+简单的通讯录
    DataList中动态添加控件遇到的问题
    伤心啊!不知道怎么感冒了
    存储过程实现无限级分类(2)
    上传文件类
    一个用泛型,和Sql语句分页的源代码
    在GridView中用Js实现全选
    [转]如何完美应对面试
  • 原文地址:https://www.cnblogs.com/yanyyx/p/1388609.html
Copyright © 2011-2022 走看看