473,799 Members | 3,740 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Update of a Master-Detail Hierarchy of Three levels

Hello,

I face a problem concerning an Update of a Master-Detail Hierarchy of Three
levels.

• tblWorkOrders (Master)
• PK: workorderID

o tblWorkOrderTas ks (Detail)
o PK: workorderTaskID
o FK: workorderID

 tblConsumedMate rials (Detail to tblWorkOrderTas ks)
 PK: materialID
 FK: workorderTaskID

All PK’s are DataType Integer and AutoIncrement.

The DataGrids are bound like:

Me.DataGridWork Orders.DataMemb er = "tblWorkord ers"
Me.DataGridWork Orders.DataSour ce = Me.dsWorkOrders

Me.DataGridWork OrderTasks.Data Member =
"tblWorkorders. tblWorkorders_t blWorkorderTask s"
Me.DataGridWork OrderTasks.Data Source = Me.dsWorkOrders

Me.DataGridCons umedMaterials.A utoEdit = True
Me.DataGridCons umedMaterials.D ataMember =
"tblWorkorders. tblWorkorders_t blWorkorderTask s.tblWorkorderT asks_tblConsume dMaterials"

So they share the same “Base Path”.

(suppose a new workorderTaskID should be 159)

When I add a new row to DataGridWorkOrd erTasks AND there were already
existing rows for that workorder, then there is no problem (the right FK is
inserted – workorderTaskID = 159)

When I add a new row to DataGridWorkOrd erTasks AND there is NO row yet for
that workorder, then there is a problem because the FK is “too high”
(workorderTaskI D = 160 or higher).
Performing the update (to the DB) then still doesn’t produce a problem.

BUT

If I have that situation and (after adding that new ‘first’ row to
DataGridWorkOrd erTasks) add a new (of course) ‘first’ row to
DataGridConsume dMaterials, then the update will raise an error (FK
workorderTaskID in tblWorkorderTas ks) because workorderTaskID = 160 does not
exist.

What seems to happen when calling the SqlDataAdapters .Update-Methods:

1. sdaWorkOrders.U pdate(dsWorkOrd ers.GetChanges( DataRowState.Ad ded))
[workorderID existed already]
2. sdaWorkOrderTas ks.Update(dsWor kOrders.GetChan ges(DataRowStat e.Added))
[New workorderTaskID Created 160 ->SQL Server makes that 159]
3. sdaConsumedMate rials.Update(ds WorkOrders.GetC hanges(DataRowS tate.Added))
[New Row’s FK Set 160 -> does not exist -> FK-Error Raised]

This is purely caused because I have a hierarchy 3 levels deep combined we
three “complex” datacontrols.

TIA,

Michael
Nov 21 '05 #1
0 952

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
8425
by: PawelR | last post by:
Hello Group, In my apps I fill DataSet from MSAcces (file db1.mdb) oleDbDataAdapter1.Fill(fromAccessDS,"MyTable") MyTable heve 4 columns, I change in dataGrid (dataGrid.DataSource=fromAccessDS.Tables) value in this table. My question: How update Table in file db1.mdb), save my change in this table?
4
7652
by: Igor Kryltsov | last post by:
Hi, If you can help me to correct my mistake. To simplify my question: I have table: create table test ( name varchar(10),
1
6437
by: Joseph Chase | last post by:
I am running version 4.1.13a-log on a Mac XServe. How can I receive a 'duplicate entry' error for an UPDATE? An update isn't creating an entry, so why this error message? ____________________________________________________ 060427 11:57:23 Slave SQL thread initialized, starting replication in log 'kiosk1-bin.000006' at position 7233, relay log './royaldemo-2-relay-bin.000007' position: 7321 060427 11:57:23 Slave: Query caused...
8
2201
by: savvy | last post by:
I'm developing a shopping cart. I've assigned some Session values to Labels on the Master Page. The Basket panel which is small window for the basket items will be visible on every page if there are any items in the basket. It will display Total Quantity and Total Price in that window. The Master Page code shown below protected void Page_Load(object sender, EventArgs e) { if (Convert.ToString(Session) != string.Empty) {
0
2117
by: Managed Code | last post by:
Hello All, Here is my issue and thanks in advance for any assistance. I have a base page with a dropdownlist that fires an event with the selected index. The content page catches the event and sets a connection string to the database. The content page has a simple gridview that should show records from the selected database. Initial content page displays data from correct place. first change of dropdownlist correctly updates content...
1
2207
by: Dmitri | last post by:
Hi! I have a stored procedure that takes 22 minutes to run in one environment, that only takes 1 sec or so to run in another environment. Here is the exact situation: Database 1 on Server 1 vs. Database 2 on Server 2 - the data is exactly the same, and the tables and index structures are exactly the same. Implicit transactions are turned off on both databases.
3
2122
by: Alvin SIU | last post by:
Hi all, I am using DB2 in AIX. I have a master table and a txn table. The master table has many many records. Each month, there is a new txn table.
1
1033
by: cmorga23 | last post by:
How do I combine the following two update query's???? Example: UPDATE py_per_stu_email SET py_eml_un = (SELECT py_email_un FROM master WHERE master.id = py_per_stu_email.id) Where py_eml_un ISNULL UPDATE py_per_stu_email SET py_eml_default = (SELECT py_email_un FROM master WHERE master.id = py_per_stu_email.id) Where py_eml_default ISNULL
1
2004
by: Rosy | last post by:
I have a form "A" that is set on table vessel names. I have subform "B" that is set on table vessel info. I want form "B" to update based on what vessel I choose in form "A". I know this is an easy one. :)
1
1152
by: Sharma Neha | last post by:
I hav a problem in sql query.I m using C#.net and working on window form,Database is SqlSever. There is a table tracking which has key_no,status as its field. There is another table master which has slno,key_no,etc as its field. In my form i hav a textbox in which one enters slno,so using this slno i want to get key_no from master table using Select query and then use this key_no to update the status in tracking table. I have used the...
0
10485
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...
1
10231
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10027
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...
0
9073
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6805
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
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4141
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3759
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.