473,794 Members | 2,880 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Updating Master – Detail Records

Echooff3
22 New Member
My application utilizes a dataset with a couple of One to Many relations. If the user adds a new record and adds information to the master part of the form and adds information to the detail part of the form then clicks save. The master record gets saved and the detail throws a “INSERT statement conflicted with the FOREIGN KEY constraint … The conflict occurred in “MasterTable”, “MasterTableID” .

My save routine goes like this:
Expand|Select|Wrap|Line Numbers
  1. Me.Validate () ‘ Validates the form
  2. MasterBindingSource.EndEdit
  3. MasterTableTableAdapter.Update(DataSet.MasterTable)
  4. DetailBindingsource.EndEdit
  5. DetailTableAdapter.Update(DataSet.DetailTable)
  6.  
I checked the row data for the Master Table and it’s identity updated from 0 to the next ID. When I check the foreign column on the Detail table it’s still 0. So when the update hits the constraint is invalid and throws the error. Blaming the Master Table even though it has the updated ID. Is there something wrong in my EndEdit / Update Sequence that the foreign key on the detail table is not updating???
Dec 5 '07 #1
1 2346
Echooff3
22 New Member
I think I have answered my issue. I removed the default FILL statement (in the form load event) that gets autogenerated in the IDE. My application pulls over 20K records so that would create a huge lag in performance. So when I called AddNew from the Master BindingSource it left the ID as 0. And sending 0 as the foreign key values to all the detail tables. So I created a query in my datatables to pull the Last record and load up the dataset intially. I don't understand why this works? Why is it necessary to fill the dataset before adding a new record?

When I update without calling inital Fill it updates the Master record fine but the changes don't propigate through the subtables. But if I call the fill first it does propigate???

Can some one explain this to me?
Dec 5 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2536
by: Ozgur YASAR | last post by:
Hi, i need to be able to active; on the first page a process is started with a (master) record insert and it will open next page on the next page a datagrid will be used to insert update delete detail vales of the master record finally the "save" button will actually save the inputs master-detail
2
1299
by: HS1 | last post by:
Hello all I followed the example in Visual Studio.net to create a master and detail relationship as following: two tables: Customers and Orders two DataGrid: GridOrders and GridDetails -------------- Dim myDataRelation As DataRelation
9
1728
by: Mr Newbie | last post by:
HI People, Thanks to all who helped me earlier on the subject of @@IDentity. However, I seem to have hit another snagette! My DataSet contains two tables from the SQL Server. lets say Master and Details. The way I have it set up is that a relationship exists in the DataSet between the two to force referential integrety etc. I am now able to a master record in the master table and add records to the
0
1709
by: Sam | last post by:
Folks, Attached I am sending 2 URL's from MSFT ASP.net Quick Start Tutorial Web Site. 1) Run it URL: http://www.asp.net/QuickStart/aspnet/samples/data/GridViewMasterDetailsInsertPage_vb.aspx 2) View Source URL: http://www.asp.net/QuickStart/util/srcview.aspx?path=~/aspnet/samples/data/GridViewMasterDetailsInsertPage.src I do understand from the Master Page (GridViewMasterDetailsInsertPage_vb.aspx) the last field from Gridview1
1
2183
by: Sam | last post by:
Attached I am sending 2 URL's from MSFT ASP.net Quick Start Tutorial Web Site. 1) Run it URL: http://www.asp.net/QuickStart/aspnet/samples/data/GridViewMasterDetai... 2) View Source URL: http://www.asp.net/QuickStart/util/srcview.aspx?path=~/aspnet/samples...
0
1302
by: Sam | last post by:
Sorry to post the same post multiple times but the URL Addresses were not Correct in Earlier Posts. Here are the correct URL's: 1) Run It URL is here: http://www.asp.net/QuickStart/aspnet/samples/data/GridViewMasterDetailsInsertPage_vb.aspx
1
1262
by: Parasyke | last post by:
I have a dilemma. I have 20 branch offices that need to be able to upload their unique copy of all their backend tables to a master database at a corporate office. I really need only a copy of those new records, deleted records , or changed records (but I guess exporting all the data would not be a problem, not very big tables). Can I write a query that updates the master database tables at corporate and have that query launched on demand...
7
4540
by: john | last post by:
In my form I have a master table and a details table linked 1xM. I can search through the whole parent table but I also like to be able to search through the child table fields to find parent records. Should I design a new form for this or can I somehow make this work in the same form. Thanks in advance, john
2
2288
by: John | last post by:
Hi I am trying to create a master/detail form. I have my master and details tables dragged onto the dataset. I have also dragged the fields from master table on the form which has created the navigation toolbar for me and which works fine with the master table. I also have a dataview on the same form ready for detail table but as yet not assigned to the detail table. How can I now create a master/detail relationship between my master and...
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10435
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10213
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6779
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.