Page 1 of 1
problem with master-detail
Posted: Thu 11 Sep 2008 03:12
by yulianto
I am using BDS 2006 and sdac 450 pro.
I have 2 table reservation and reservationdetail.
reservation:
- ReservationID (autoinc)
reservationdetail :
- ReservationDetailID (autoinc)
- reservationID (fk to reservation)
master tmsquery setting :
SQL = Select * from reservation
cachedupdate = true
returnparams = true
detail tmsquery setting :
SQL = select * from reservationdetail where reservationid=:reservationid
mastersource = master
cahcedupdate = true
returnparams = true
localmasterdetail = true
However the master-detail won't work. i have dbgird to show my detail data but it still empty.
I've try to use masterfield and detailfield solution like you did in the doc. It's work HOWEVER i can't append a new data on detail dbgrid beacuse the data will disappear every time i post or append new record.
Am i doing something wrong? Thanks before.
Posted: Thu 11 Sep 2008 08:34
by Dimon
When you use the CachedUpdates mode you should write dataset's changes to a database using the TMSQuery.ApplyUpdates and the TMSQuery.CommitUpdates methods.
Posted: Thu 11 Sep 2008 08:42
by yulianto
thank you for quick response....
However i've done what you said.
Code: Select all
if dmReservation.QReservation.State in [dsedit, dsinsert] then begin
dmReservation.QReservation.Connection.StartTransaction;
try
dmReservation.QReservation.ApplyUpdates;
dmReservation.QReservationDetail.ApplyUpdates;
dmReservation.QReservation.Connection.Commit;
dmReservation.QReservation.CommitUpdates;
dmReservation.QReservationDetail.CommitUpdates;
BrowseMode;
except
dmReservation.QReservation.RestoreUpdates;
dmReservation.QReservationDetail.RestoreUpdates;
dmReservation.QReservation.Connection.Rollback;
end;
end;
I've also add this:
Code: Select all
// for master table
procedure TdmReservation.QReservationBeforeUpdateExecute(
Sender: TCustomMSDataSet; StatementTypes: TStatementTypes; Params: TMSParams);
begin
if stInsert in StatementTypes then begin
Params.ParamByName('ReservationID').ParamType:=ptInputOutput;
end;
end;
//for detail table
procedure TdmReservation.QReservationDetailBeforeUpdateExecute(
Sender: TCustomMSDataSet; StatementTypes: TStatementTypes; Params: TMSParams);
begin
if stInsert in StatementTypes then begin
Params.ParamByName('ReservationID').AsInteger:=QReservationReservationID.AsInteger;
end;
end;
My real problem is, after i apply updates my change and i re-run my application, the master-detail won't work. i get master data but detail dbgid is empty (I am using master-detail with parameter)
Posted: Thu 11 Sep 2008 08:55
by Dimon
Please try to compose a small sample to demonstrate the problem and send it to dmitryg*devart*com.
Posted: Thu 11 Sep 2008 09:38
by yulianto
i've sent you the sample...
thanks in advance.

Posted: Thu 11 Sep 2008 14:36
by Dimon
Thank you for information. We have reproduced this problem and fixed it. This fix will be included in the next SDAC build.
Posted: Fri 12 Sep 2008 07:56
by yulianto
do you have any alternative solution for this problem? at least until the next build released...
Posted: Mon 15 Sep 2008 08:02
by Dimon
Unfortunately, we don't have an alternative solution for this problem. If you can, don't use the CahcedUpdate mode.
Posted: Thu 18 Sep 2008 06:18
by lifeform
when the next release released???
please tell us the estimated date so we can estimate our project too
Posted: Fri 19 Sep 2008 08:00
by Dimon
The next SDAC build will be released at the beginning of the next week.