By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,815 Members | 1,142 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,815 IT Pros & Developers. It's quick & easy.

Dataset update error (record requires parent table record)

P: n/a
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

Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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
Nov 21 '05 #2

P: n/a

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" <pa**@nospam.wanadoo.co.uk> wrote in message
news:dh**********@newsg1.svr.pol.co.uk:
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


Nov 21 '05 #3

P: n/a
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.Update(childrenTbl.Select(null, null,
DataViewRowState.Deleted));
sqlParentsDA.Update(parentsTbl.Select(null, null,
DataViewRowState.Deleted));

sqlChildrenDA.Update(childrenTbl.Select(null, null,
DataViewRowState.ModifiedCurrent));
sqlParentsDA.Update(parentsTbl.Select(null, null,
DataViewRowState.ModifiedCurrent));

sqlParentsDA.Update(parentsTbl.Select(null, null, DataViewRowState.Added));
sqlChildrenDA.Update(childrenTbl.Select(null, null,
DataViewRowState.Added));

"PAUL" <pa**@nospam.wanadoo.co.uk> wrote in message
news:dh**********@news6.svr.pol.co.uk...
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

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.