473,219 Members | 1,653 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,219 software developers and data experts.

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.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
3 2375
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

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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Fraser Hanson | last post by:
Hello, I have a table which has a foreign key relationship with itself. I want and expect my updates to cascade (deletes definitely cascade as expected) but instead I just get error 1217:...
1
by: Stephen Ritchie | last post by:
I have a dataset that contains two tables - Parent and Child. The key of the Parent is called ParentID and is an identity column in SQL Server. The key of the Child is two columns called ParentID -...
0
by: oj | last post by:
I have a dataset with a parent table and 3 child tables. The dataset is filled and manipulated on one particular web page. During the user interaction one of the child tables can have records...
0
by: M. David Johnson | last post by:
I cannot get my OleDbDataAdapter to update my database table from my local dataset table. The Knowledge Base doesn't seem to help - see item 10 below. I have a Microsoft Access 2000 database...
9
by: jaYPee | last post by:
I have search a lot of thread in google newsgroup and read a lot of articles but still i don't know how to update the dataset that has 3 tables. my 3 tables looks like the 3 tables from...
10
by: jaYPee | last post by:
does anyone experienced slowness when updating a dataset using AcceptChanges? when calling this code it takes many seconds to update the database SqlDataAdapter1.Update(DsStudentCourse1)...
8
by: Dot Net Newbie | last post by:
New to DOTNET so please be gentle: I have an in-memory dataset that I want move to a SQL Server database. The XML schema with which the dataset was built matches exactly the table schema in SQL...
1
by: James Hallam | last post by:
I have a parent record with a child record. The parent record contains structures and the child records contains visits to those structures. Each table has a field named "Complete", what I...
0
by: dentyne | last post by:
Good morning, I have a typed dataset with 10 relational, hierarchical tables. I want to be able to "filter" all the dataset tables based on one parent record. For instance, let's say I have a...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.