My OS is W-XP-Prof and have been using Delphi 6 Enterprise for many years.
In the process I have successfully relied on ApplyUpdates as below.
ModifySQL.Clear;
ModifySQL.Add ('update');
if (dmStdAcc.PivotTbl1KeyOrigin.value = 'GL')then
ModifySQL.Add ('''C:\h\StdAcc\'+ IntToStr(dmStdAcc.PivotTbl1PNo.AsInteger) + '\GenAccs''');
ModifySQL.Add ('set');
ModifySQL.Add ('LAccNo = :LAccNo, LAccNo2 = :LAccNo2, AccDate = :AccDate, Doc = oc, FileNo = :FileNo, Vat = :Vat,');
ModifySQL.Add ('OppAccName = :OppAccName, OppAccNo = :OppAccNo, OppAccNo2 = :OppAccNo2, Amount = :Amount, Balance = :Balance, Job = :Job');
ModifySQL.Add ('where');
ModifySQL.Add ('Akv = :OLD_Akv');
InsertSQL.Clear;
InsertSQL.Add ('insert into');
if (dmStdAcc.PivotTbl1KeyOrigin.value = 'GL') then
InsertSQL.Add ('''C:\h\StdAcc\' + IntToStr(dmStdAcc.PivotTbl1PNo.AsInteger) + '\GenAccs''');
//Insert SQL for BOTH Ledger Accounts
InsertSQL.Add ('(LAccNo, LAccNo2, AccDate, Doc, FileNo, Vat, OppAccName, OppAccNo,');
InsertSQL.Add ('OppAccNo2, Amount, Balance, Job)');
InsertSQL.Add ('values');
InsertSQL.Add ('LAccNo, :LAccNo2, :AccDate, oc, :FileNo, :Vat, :OppAccName, :OppAccNo, :OppAccNo2, :Amount, :Balance, :Job)');
DeleteSQL.Clear;
DeleteSQL.Add ('delete from');
if (dmStdAcc.PivotTbl1KeyOrigin.value = 'GL') then
DeleteSQL.Add ('''C:\h\StdAcc\' + IntToStr(dmStdAcc.PivotTbl1PNo.AsInteger) + '\GenAccs''');
DeleteSQL.Add ('where');
DeleteSQL.Add ('Akv = :OLD_Akv');
if dmStdAcc.qryAccount.UpdatesPending then
dmStdAcc.qryAccount.ApplyUpdates;
More recently, after having done some re-engineering elsewhere in the Application, the ApplyUpdates [as above] still works successfully ONCE! BUT in a sequential attempt immediately afterwards I get exception "Update has failed".
What am I missing? What might I have done during re-engineering to upset this?
delphiman
Old Man Delphi
In the process I have successfully relied on ApplyUpdates as below.
ModifySQL.Clear;
ModifySQL.Add ('update');
if (dmStdAcc.PivotTbl1KeyOrigin.value = 'GL')then
ModifySQL.Add ('''C:\h\StdAcc\'+ IntToStr(dmStdAcc.PivotTbl1PNo.AsInteger) + '\GenAccs''');
ModifySQL.Add ('set');
ModifySQL.Add ('LAccNo = :LAccNo, LAccNo2 = :LAccNo2, AccDate = :AccDate, Doc = oc, FileNo = :FileNo, Vat = :Vat,');
ModifySQL.Add ('OppAccName = :OppAccName, OppAccNo = :OppAccNo, OppAccNo2 = :OppAccNo2, Amount = :Amount, Balance = :Balance, Job = :Job');
ModifySQL.Add ('where');
ModifySQL.Add ('Akv = :OLD_Akv');
InsertSQL.Clear;
InsertSQL.Add ('insert into');
if (dmStdAcc.PivotTbl1KeyOrigin.value = 'GL') then
InsertSQL.Add ('''C:\h\StdAcc\' + IntToStr(dmStdAcc.PivotTbl1PNo.AsInteger) + '\GenAccs''');
//Insert SQL for BOTH Ledger Accounts
InsertSQL.Add ('(LAccNo, LAccNo2, AccDate, Doc, FileNo, Vat, OppAccName, OppAccNo,');
InsertSQL.Add ('OppAccNo2, Amount, Balance, Job)');
InsertSQL.Add ('values');
InsertSQL.Add ('LAccNo, :LAccNo2, :AccDate, oc, :FileNo, :Vat, :OppAccName, :OppAccNo, :OppAccNo2, :Amount, :Balance, :Job)');
DeleteSQL.Clear;
DeleteSQL.Add ('delete from');
if (dmStdAcc.PivotTbl1KeyOrigin.value = 'GL') then
DeleteSQL.Add ('''C:\h\StdAcc\' + IntToStr(dmStdAcc.PivotTbl1PNo.AsInteger) + '\GenAccs''');
DeleteSQL.Add ('where');
DeleteSQL.Add ('Akv = :OLD_Akv');
if dmStdAcc.qryAccount.UpdatesPending then
dmStdAcc.qryAccount.ApplyUpdates;
More recently, after having done some re-engineering elsewhere in the Application, the ApplyUpdates [as above] still works successfully ONCE! BUT in a sequential attempt immediately afterwards I get exception "Update has failed".
What am I missing? What might I have done during re-engineering to upset this?
delphiman
Old Man Delphi