Groups | Blog | Home
all groups > dotnet ado.net > september 2005 >

dotnet ado.net : Dataset update error (record requires parent table record)


PAUL
9/30/2005 3:00:12 PM
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.Transaction = trnMain
daObjectsTable.InsertCommand.Transaction = trnMain
daObjectsTable.UpdateCommand.Transaction = trnMain
daObjectsTable.Update(dsIssue, "tblObjects")

'Update child table (fails on update)
daAffectedObjects.DeleteCommand.Transaction = trnMain
daAffectedObjects.InsertCommand.Transaction = trnMain
daAffectedObjects.UpdateCommand.Transaction = trnMain
daAffectedObjects.Update(dsIssue, "tblAffectedObjects") <---- Fails here


PAUL
9/30/2005 3:11:20 PM
Hello,
I have a dataset where in only 1 place is the data amended, however
when run the update statement:

daSomethingTable.Update(dsIssue, "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

scorpion53061
9/30/2005 6:58:38 PM

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.

[quoted text, click to view]
AddThis Social Bookmark Button