AD
Administrator
Syncfusion Team
May 20, 2005 01:53 PM UTC
So, it seems the problem is that the DataBase is resetting a value in the new master table, is this correct?
One possible work around would be to go ahead and save the new row master table before adding related entries in the child table. Then hopefully, the values would not change. You could try just calling datatable.AcceptChanges on the master table to see if that would do it. If not, then you would probably have to update the database to get the new row finalized with the proper primary key.
Instead of trying to save the new master rows to the database one at the time, another option might be to wait. Then when you need ot save things, save the master table first keeping track of whether new records are being chnaged, and then make any necessary modifiecation in the child table before saving it.
Another option might be querying the database for the next primary key and making sure the new row is using this key. I am not sure how you might do this.
HS
Helmut Scheiss
May 20, 2005 09:14 PM UTC
Just to make sure you have enough information. There are two DataAdapters:
daMaster and daDetail
daMaster uses this SP to get its data:
PROCEDURE getMasterRecs(@qaID int)
AS
SELECT d.QADetailID,
d.QAID,
d.Description
FROM
tblMaster d LEFT OUTER JOIN
tblDetail dd ON d.QADetailID = dd.QADetailID
WHERE
QAID = @qaid
daDetail uses this SP to select its records:
PROCEDURE getDetailRecs(@qaID int)
AS
SELECT dd.DetailDetailID,
dd.QADetailID,
dd.Description
FROM
tblDetail dd,
tblMaster, d
WHERE
dd.QADetailID = d.QADetailID AND
d.QAID = @qaid
There is a FK constraint on Master.QADetailID and Detail.QADetailID.
When I setup my grids, the Master Grid uses the dataset as its datasource and getMasterRecs as its DataMember. The Detail Grid uses the same dataset as its datasource and its DataMember is set to the constraint.
I am now storing the original Master.QADetailID into a field, Master.OldQADetailID.
What I think I have to do is after Updating the Master table, loop through all of the Detail Datarows and change the Detail.QADetailID to the new Master.QADetailID.
Is this kludgey or is there some better way?
PS:Not sure how to loop through detail recs to set their values prior to doing an update.....