The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Bill Vaughn blogs, and I ask an ADO.Net question

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Roy Osherove

Posts: 1807
Nickname: royo
Registered: Sep, 2003

Roy Osherove is a .Net consultant based in Israel
Bill Vaughn blogs, and I ask an ADO.Net question Posted: Apr 29, 2004 5:32 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Roy Osherove.
Original Post: Bill Vaughn blogs, and I ask an ADO.Net question
Feed Title: ISerializable
Feed URL: http://www.asp.net/err404.htm?aspxerrorpath=/rosherove/Rss.aspx
Feed Description: Roy Osherove's persistent thoughts
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Roy Osherove
Latest Posts From ISerializable

Advertisement
I've been reading an hearing some of Bill's thoughts on Data Access in the recent past and all I can say is that I wish I knew all the stuff he's already forgotten about ADO.Net and Data Access techniques in general. Subscribed.
 
Now, here's something for Bill to gnaw on, since he specifically said 
“I've been known to answer questions when I can and I try not to make up the answer when I can't...” 
 
Context:
  • You have a Dataset that contains one parent table and one child table (with a relation between them).
  • The Parent table has a primary key comprising of Identity Values that needs to be reconciled with the database.
  • The Relation between the two tables is declared as “Cascade Update” and “Cascade Delete”.
  • You have a new row in the parent table and some new child rows for that row in the child table that you need to add to the database.
  • To save bandwidth, you use the GetChanges() method of the dataset and update those values.
  • The update succeeds and also retrieves back the new identity value of the new row (following all the steps mentioned in this MSDN article)
  • Identity columns are set to -1 with an increment of -1 to prevent database collisions
Problem:
Trying to merge the changed dataset with the original produces a ContraintException due to some sort of problem with the child rows in the child table(even though Cascade update is set to true). This problem does not occur if there are no new child rows to be updated as well.
 
Possible Solutions?
  • This article seems like a possible way to resolve this. What do you think?
  • I've heard on one of the recent .Net Rocks shows that Bill suggested approaching this problem by actually creating some empty rows on the database first instead of creating them in memory, thus preventing an constraint conflicts. However, it was mentioned as an afterthought to the conversation and I'm not sure that's the most elegant solution here.
  • [Added later] Here's Bill's article on this issue. I'll read it and see how it fits the problem.
  • [Added later]  Bill has many other cool and useful articles on his website. I'll have a look see when I get some time this weekend.

Read: Bill Vaughn blogs, and I ask an ADO.Net question

Topic: Developing with NUnit Part 1 Previous Topic   Next Topic Topic: New book: Build your own ASP.Net using C# & VB.Net

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use