Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with UpdateRecord.

Status
Not open for further replies.

delphiman

Programmer
Dec 13, 2001
422
ZA

If Special Procedure (spDelP) at point "A" below returns "uaFail" I get a "Table is read
only" exception at point "B". Which then also results in the Application locking up.
So that Ctrl+Alt+Del has to be used to end the program.

Can anyone tell me what I am overlooking?
How do I overcome this problem?


procedure TdmFamily.qryParentUpdateRecord(DataSet: TDataSet;
UpdateKind: TUpdateKind; var UpdateAction: TUpdateAction);
begin
if UpdateKind = ukDelete then
begin
with dmFamily do
spDelP.Params[0].Value := qryParentP_No_OldValue;
try
dmFamily.spDelP.ExecProc; .......................A
UpdateAction := uaApplied;
except
UpdateAction := uaFail; ..........................B
end;
end
else
try
// apply updates
dmFamily.updParent.Apply(UpdateKind);
UpdateAction := uaApplied;
except
UpdateAction := uaFail;
end;
end;
 
First, "Special Procedure (spDelP) at point "A" below returns "uaFail". It does not "return" uaFail. You might be looking at the UpdateAction argument that was passed in, but inside exception blocks, values can get weird. I suggest you put these values into local variables where you can watch them. Also make sure that DataSet is really qryParantP_No.

Second, what are you trying to do? It looks like you are trying to use a stored procedure to delete instead of letting the cached update do it. If so, you could try to do this in BeforeDelete; it might make a difference.

Cheers
 
Thanks for that.

I got this got out of Mastering Delphi 6 by Marco Cantu.

The routine is working in a Master/Detail relationship.
In a normal situation (where the Master has no Detail) it works fine. But the moment there are and records in the Detail it still works but the routine comes unstuck as explained.
 
>you could try to do this in BeforeDelete

Still have the problem.

Anyone else .......?? :)
 
FIXED!!

I neglected to notice another (very important) Procedure in
Marco Cantu's example. Which gets me out of the loop.

From this

1 Upon closing the form one is confronted with "Data has been changed. Save changes?"
2 Having selected the "Yes" button one is confronted with the "Table is read-only".
3 Having clicked on "O.K." One is again left with trying to Exit the form.
4 This time one selects "No" to "Data has been changed. Save changes?" .... and that's that! :)


With apologies to Marco Cantu this is at the bottom of Page 615 which looks like this..

procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
var
Res: Integer;
begin
with dmData do
if qryEmployee.UpdatesPending then
begin
Res := MessageDlg(CloseMsg, mtInformation, mbYesNoCancel, 0);
if Res = mrYes then
AppDB.ApplyUpdates([qryEmployee]);
CanClose := Res <> mrCancel;
end;
end;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top