//保存单据
if (Assigned(dsMaster.DataSet)) and (Assigned(dsDetail.DataSet)) then
begin
if (dsMaster.DataSet.Active) and (dsDetail.DataSet.Active) then
begin
try
frmDM.MyConnection.StartTransaction;
if Trim(dsMaster.DataSet.FieldByName('cust_id').AsString) ='' then
MDRelationValue := GetMaxId;
begin
dsMaster.DataSet.FieldByName('cust_id').AsString := MDRelationValue;
if not (dsDetail.DataSet.State in [dsInsert, dsEdit]) then dsDetail.DataSet.Edit;
dsDetail.DataSet.DisableControls;
if dsDetail.DataSet.RecordCount <> 0 then
begin
dsDetail.DataSet.First;
while not dsDetail.DataSet.Eof do // Iterate
begin
if not (dsDetail.DataSet.State in [dsInsert, dsEdit]) then
dsDetail.DataSet.Edit;
dsDetail.DataSet.FieldByName('cust_id').AsString := MDRelationValue;
dsDetail.DataSet.Next;
end; // for
end;
dsDetail.DataSet.EnableControls;
end; if dsMaster.DataSet.State in [dsInsert, dsEdit] then
dsMaster.DataSet.Post; dsDetail.DataSet.DisableControls;
if not (dsDetail.DataSet.State in [dsInsert, dsEdit]) then
dsDetail.DataSet.Edit;
dsDetail.DataSet.Post;
dsDetail.DataSet.EnableControls; frmDM.MyConnection.Commit;
except // wrapup异常
on Ex:Exception do
begin
dsDetail.DataSet.EnableControls;
frmDM.MyConnection.Rollback;
raise;
end;
end; // try/end
我是用两个TmyQuery做的主明细数据集,qryDetail的masterField 为qryMaster的‘cust_id'这样做的关联,在提交时出现“cannot use master/detail with cachupdates”的错误,
请教下有没有什么好的方法在使用本地缓存的情况下同时提交主明细记录,谢谢
if (Assigned(dsMaster.DataSet)) and (Assigned(dsDetail.DataSet)) then
begin
if (dsMaster.DataSet.Active) and (dsDetail.DataSet.Active) then
begin
try
frmDM.MyConnection.StartTransaction;
if Trim(dsMaster.DataSet.FieldByName('cust_id').AsString) ='' then
MDRelationValue := GetMaxId;
begin
dsMaster.DataSet.FieldByName('cust_id').AsString := MDRelationValue;
if not (dsDetail.DataSet.State in [dsInsert, dsEdit]) then dsDetail.DataSet.Edit;
dsDetail.DataSet.DisableControls;
if dsDetail.DataSet.RecordCount <> 0 then
begin
dsDetail.DataSet.First;
while not dsDetail.DataSet.Eof do // Iterate
begin
if not (dsDetail.DataSet.State in [dsInsert, dsEdit]) then
dsDetail.DataSet.Edit;
dsDetail.DataSet.FieldByName('cust_id').AsString := MDRelationValue;
dsDetail.DataSet.Next;
end; // for
end;
dsDetail.DataSet.EnableControls;
end; if dsMaster.DataSet.State in [dsInsert, dsEdit] then
dsMaster.DataSet.Post; dsDetail.DataSet.DisableControls;
if not (dsDetail.DataSet.State in [dsInsert, dsEdit]) then
dsDetail.DataSet.Edit;
dsDetail.DataSet.Post;
dsDetail.DataSet.EnableControls; frmDM.MyConnection.Commit;
except // wrapup异常
on Ex:Exception do
begin
dsDetail.DataSet.EnableControls;
frmDM.MyConnection.Rollback;
raise;
end;
end; // try/end
我是用两个TmyQuery做的主明细数据集,qryDetail的masterField 为qryMaster的‘cust_id'这样做的关联,在提交时出现“cannot use master/detail with cachupdates”的错误,
请教下有没有什么好的方法在使用本地缓存的情况下同时提交主明细记录,谢谢
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货