473,327 Members | 1,919 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,327 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 2382
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.