Disclaimer - I don't know as this is an UltraGrid issue but maybe someone will recognize what's going on here.
Building a master/detail data entry form. Master table has a field masterID which is an identity field and is the PK of the table. Detail table has a detailID identity field which is the PK and a masterID field which is an FK against the master.
Have a dataset with table adapters and hierarchical update is set to true. Relation exists on the dataset between master and detail on the masterID field, set to Both Relation and Foreign Key Constraint. Update and Delete rules set to Cascade.
I have a form with the master table dragged onto it using Details (so I get one control per field in the master table), and the details table dragged onto the form as a UltraGrid from under the Master table (so the relation is used to select detail records). This works - the relation is displaying the expected detail records as the master record changes.
The problem is this - when a new record is inserted in the master table it gets an ID of -1 until it is saved. Any detail records created are cascaded that value in the masterID field when they are created.
Now, what is supposed to happen is that when you execute the DataSet.UpdateAll command
What is happening, though, is that the save is failing with a message saying the masterID of -1 cannot be inserted in the detail table because it does not exist in the master table. Now, normally I'd conclude this is an MS problem except ... this failure doesn't happen if I use a MS DataGridView for the child table instead of an UltraGrid. With the DataGridView, the updates are cascaded and the saves happen as expected. I can take a form that works with the DataGridView, substitute an UltraGrid, and it stops working.
With the UltraGrid, if I create the master record, save it, and then create the detail records, it all works.
I have to think I've applied (unknowingly) some setting to the UltraGrid that is causing this to fail.
Has anyone any suggestions as to what might be bringing this on and how to correct?
TIA
Awww crap ... never mind, I'm an idiot. I missed one crucial piece of code on the UltraGrid form that was there on the DataGridView version.
Private Sub DetailBindingSource_AddingNew(sender As Object, e As System.ComponentModel.AddingNewEventArgs) Handles DetailBindingSource.AddingNew Me.MasterBindingSource.EndEdit()End Sub
Hello,
It appears that you have resolved your issue. Please let me know if you have any other questions about this.