I've got a cached master/detail table and everything works great on the initial entry of an item. However after posting, applying, and committing changes the detail table does not have the record key of the master table. I've set it up according to instructions given in the help file, and according to it, this relationship should be created automatically.
Does it not happen with a cached master/detail entry? I'm using a cached entry so that users can cancel out of the data entry form and no updates are made.
Is there something additional I should be doing because I am caching?
I've noticed in the help file there is this statement under cachedupdates property:
NOTE: When establishing master/detail relationship the CachedUpdates property of detail dataset works properly only when TCustomDADataSet.Options is set to True.
Options has more than one property, so how can it be set to true. Through some additional research I assume that it means the LocalMasterDetail option. Is there anything else that needs to be set? Because, as I said, the master detail relationship works initially, but the values for the link are not being posted to the detail database.
I've also tried to forcibly post the values to the detail record link by setting them manually in the Update record event. But with a trace, the values show, but they are still not being posted.
Master Detail Cache Update
When establishing master-detail relationship the CachedUpdates property of detail dataset works properly only when TCustomDADataSet.Options.LocalMasterDetail is set to True. Therefore to solve the problem you should set the LocalMasterDetail option to True.
You can find more detailed information about this in the MyDAC help.
You can find more detailed information about this in the MyDAC help.
-
doublehelix
- Posts: 9
- Joined: Mon 28 Dec 2009 23:42
Done that
Dimon wrote:When establishing master-detail relationship the CachedUpdates property of detail dataset works properly only when TCustomDADataSet.Options.LocalMasterDetail is set to True. Therefore to solve the problem you should set the LocalMasterDetail option to True.
You can find more detailed information about this in the MyDAC help.
I've done this, and yes, when this option is not set the caching will not work at all and the app errors out.
I'm using an auto-incrementing field in a customer list and linking it in a master-detail with an address list. As I said on initial entry everything appears to work properly. I'm using a tabbed entry for the addresses that will be associated with the customer record. I can move among the tabs when first entering data and the different addresses show in the appropriate tabs. However after committing the transactions the detail record link field does not contain an associated record number of the master table, its null.
-
doublehelix
- Posts: 9
- Joined: Mon 28 Dec 2009 23:42
Re: Done that
Looks like the only way around this was to finally dump the caching altogether and use the transaction rollback feature of the MyConnection. It ment I had to create a MyConnection for every form because the program is MDI and multiple customer entry forms can be opened at once.doublehelix wrote:Dimon wrote:When establishing master-detail relationship the CachedUpdates property of detail dataset works properly only when TCustomDADataSet.Options.LocalMasterDetail is set to True. Therefore to solve the problem you should set the LocalMasterDetail option to True.
You can find more detailed information about this in the MyDAC help.
I've done this, and yes, when this option is not set the caching will not work at all and the app errors out.
I'm using an auto-incrementing field in a customer list and linking it in a master-detail with an address list. As I said on initial entry everything appears to work properly. I'm using a tabbed entry for the addresses that will be associated with the customer record. I can move among the tabs when first entering data and the different addresses show in the appropriate tabs. However after committing the transactions the detail record link field does not contain an associated record number of the master table, its null.
The problem is that when you are using autoincrement values that are used as link values for detail table in master table, there is no possibility to know new autoincremented value until executing ApplyUpdate.
To solve the problem you can use the DoAfterInsert event handler, or you should insert or update records in datail table after posting changes in master table using ApplyUpdate.
To solve the problem you can use the DoAfterInsert event handler, or you should insert or update records in datail table after posting changes in master table using ApplyUpdate.