Dataset update error (record requires parent table record)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • PAUL

    #1

    Dataset update error (record requires parent table record)

    Hello,
    I have 2 datasets I am trying to update. The parent table seems to
    update fine but when I go update the chiled table I get an error message
    that says I need a related record in the parent table. However I put some
    code in to display the key field of each parent table record (parent
    dataset) and the value I am trying to put into the child table is there.

    ParentTable ChildTable
    ID------------------------< ParentTableID

    Now because I havnt commited the transaction yet the parenttable would still
    not have the new record in the DB yet, but surely it should check against
    the parent table dataset not the DB?

    As I said earlier all the records in the childtable dataset have related
    records in the parenttable dataset so I cant understand why its
    complaing....!

    Any help would be appreciated...

    Thanks
    Paul M


    'Update parent table (works ok)
    daObjectsTable. DeleteCommand.T ransaction = trnMain
    daObjectsTable. InsertCommand.T ransaction = trnMain
    daObjectsTable. UpdateCommand.T ransaction = trnMain
    daObjectsTable. Update(dsIssue, "tblObjects ")

    'Update child table (fails on update)
    daAffectedObjec ts.DeleteComman d.Transaction = trnMain
    daAffectedObjec ts.InsertComman d.Transaction = trnMain
    daAffectedObjec ts.UpdateComman d.Transaction = trnMain
    daAffectedObjec ts.Update(dsIss ue, "tblAffectedObj ects") <---- Fails here



  • PAUL

    #2
    Dataset update error (Concurrency exception)

    Hello,
    I have a dataset where in only 1 place is the data amended, however
    when run the update statement:

    daSomethingTabl e.Update(dsIssu e, "tblStuff")

    to get the changes back to the database using its dataadaptor I get a
    concurrency exception which implies that another change was made to the same
    record before update. However as I said it only gets changed in 1 specific
    line (for 1 field). When I comment out that line it goes through.

    Also I am the only person using the application & code on an isolated PC so
    I can state categorically that no one else has the record out for edit.

    Anybody got any ideas? Would be grateful for some help...

    Cheers
    Paul M


    Comment

    • scorpion53061

      #3
      Re: Dataset update error (Concurrency exception)


      Another problem that it could be is that the db value or type at the
      source or dataset level are not the same as the other or one or the
      other was changed. Check your types and length of the types to verify
      they are one and the same.

      "PAUL" <paul@nospam.wa nadoo.co.uk> wrote in message
      news:dhjh25$n2p $1@newsg1.svr.p ol.co.uk:
      [color=blue]
      > Hello,
      > I have a dataset where in only 1 place is the data amended, however
      > when run the update statement:
      >
      > daSomethingTabl e.Update(dsIssu e, "tblStuff")
      >
      > to get the changes back to the database using its dataadaptor I get a
      > concurrency exception which implies that another change was made to the same
      > record before update. However as I said it only gets changed in 1 specific
      > line (for 1 field). When I comment out that line it goes through.
      >
      > Also I am the only person using the application & code on an isolated PC so
      > I can state categorically that no one else has the record out for edit.
      >
      > Anybody got any ideas? Would be grateful for some help...
      >
      > Cheers
      > Paul M[/color]

      Comment

      • Mircea Pleteriu

        #4
        Re: Dataset update error (record requires parent table record)

        Hi,

        I experienced the same problem.
        To resolution is that you're the one which should control the update logic.
        To be more clear... you need samething like:

        sqlChildrenDA.U pdate(childrenT bl.Select(null, null,
        DataViewRowStat e.Deleted));
        sqlParentsDA.Up date(parentsTbl .Select(null, null,
        DataViewRowStat e.Deleted));

        sqlChildrenDA.U pdate(childrenT bl.Select(null, null,
        DataViewRowStat e.ModifiedCurre nt));
        sqlParentsDA.Up date(parentsTbl .Select(null, null,
        DataViewRowStat e.ModifiedCurre nt));

        sqlParentsDA.Up date(parentsTbl .Select(null, null, DataViewRowStat e.Added));
        sqlChildrenDA.U pdate(childrenT bl.Select(null, null,
        DataViewRowStat e.Added));

        "PAUL" <paul@nospam.wa nadoo.co.uk> wrote in message
        news:dhjgd9$2es $1@news6.svr.po l.co.uk...[color=blue]
        > Hello,
        > I have 2 datasets I am trying to update. The parent table seems to
        > update fine but when I go update the chiled table I get an error message
        > that says I need a related record in the parent table. However I put some
        > code in to display the key field of each parent table record (parent
        > dataset) and the value I am trying to put into the child table is there.
        >
        > ParentTable ChildTable
        > ID------------------------< ParentTableID
        >
        > Now because I havnt commited the transaction yet the parenttable would[/color]
        still[color=blue]
        > not have the new record in the DB yet, but surely it should check against
        > the parent table dataset not the DB?
        >
        > As I said earlier all the records in the childtable dataset have related
        > records in the parenttable dataset so I cant understand why its
        > complaing....!
        >
        > Any help would be appreciated...
        >
        > Thanks
        > Paul M
        >
        >
        > 'Update parent table (works ok)
        > daObjectsTable. DeleteCommand.T ransaction = trnMain
        > daObjectsTable. InsertCommand.T ransaction = trnMain
        > daObjectsTable. UpdateCommand.T ransaction = trnMain
        > daObjectsTable. Update(dsIssue, "tblObjects ")
        >
        > 'Update child table (fails on update)
        > daAffectedObjec ts.DeleteComman d.Transaction = trnMain
        > daAffectedObjec ts.InsertComman d.Transaction = trnMain
        > daAffectedObjec ts.UpdateComman d.Transaction = trnMain
        > daAffectedObjec ts.Update(dsIss ue, "tblAffectedObj ects") <---- Fails[/color]
        here[color=blue]
        >
        >
        >[/color]


        Comment

        Working...