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!

UpDateSQL - Is Marco Cantu listening out there? 3

Status
Not open for further replies.

delphiman

Programmer
Dec 13, 2001
422
ZA
I find that the UpDateSQL Example code on Page 615 of Mastering Delphi 6 only works - to a point. Then mere mortals like myself have a problem.

Which is, having successfully prevented a Delete after the first try, the wheels fall off at the first UpDateAction := uaFail.

Because then one is presented with a "Table is read only" exception. From which the user cannot escape. As described in my thread102-540756.

Is there perhaps another gury aka Marco Cantu who can help out - Puhleeeeeese

I have been struggling with overcoming this for over a week now!

Thanks in advance - anyone
 
hi

Can't help you with your problem but personnally I never use this comp. I always do my Updates, inserts and deletes in TQueries and call Execsql...much simpler, I think.

lou

 
Hi
I will try to take a look at UpDateSQL Example code on Page 615 after my holiday.
I do not have the book with me.. it is in my office..
I will try to see if I can help... I am back to work next week.

Stretchwickster could also probably help you if he have the time... :)

cheers so long..
mha
 
Thanks everyone.

weez

I am also doing my Updates, inserts and deletes in TQueries along with the qryTUpdate component. I can't see how else one can do all this. I dont understnd what you mean by and call Execsql. Could you please give some more details - perhaps some example code?

richardchaven

CachedUpdates := True? Yup! Perhaps that's the problem!! Why should that be? I'll remove it anyway and see what happens.

michaenh

Thanks for your interest. Not that I want to interrupt your holiday (where are you holidaying? I am in Melbourne Australia) but you can see the entire code in my Thread102-540756.
 
The TQuery that weez is talking about I use like this:

qrySomething.SQL.Clear;
qrySomething.SQL.Add('UPDATE SOMETABLE SET NOTHING = SOMETHING WHERE SOMETHINGELSE = MARBLES');
qrySomething.ExecSQL;

This will update the table.

HTH


Leslie
landrews@metrocourt.state.nm.us

There are 10 types of people in the world -
those who understand binary
and
those who don't!
 
Having made CachedUpdates := True I find if I try and make Active := True I get
Table is read only exception. I now remember getting this exception
at an early stage and that the only way to overcome it was to have CachedUpdates := True.

To begin (at the beginning) I am convinced that the relationships between the tables and the
Procedures in my SQL code creating the DataBase is correct and not the source of the problem.

If only because the Insert Modify and Delete procedures work perfectly.

However what has to be remembered is that my Delete procedure (quite correctly) also has to
prevent a Master record from being deleted if there is still a record in a dependant Detail.

The very reason for the code in my thread102-540756 which I got from Marco Canu's book. And
from what I can see from the breakpoint at A in my thread102-540756 the Delete Procedure
is in fact working correctly - along with my TStored Procedure component.

But somehow, the firing of the TStoredProcedure Component is causing one (I don't even know
which one - or more!) of the relevant tables to become "Read Only." Which is bad enough. But
in addition my Application then just ends up in a loop. Interupted only with "Table is
Read only" warnings.

If I could even just get the whole ball of wax to simply drop out (with EXIT - or something!),
perhaps with a little gloved hand flashing out to smack the operator between the eyes -
accompanied with a little voice saying "Dont DO that!"[/b] that would be fine -
although not desireable.

But I can't even get out - without Ctrl+Alt+Del. Which is not acceptable.

lespaul

Thanks for that .... but I don't understand Something.ExecSQL. Can you tell me more?

 
If your query component is named: qrysomething (I usually name my queries something meaningful qryJurorSearch or qryVenireUpdate) then the command to run an update, insert or delete SQL statement is

qrySomething.ExecSQL

If you just try setting the active property to true for an update, insert or delete SQL statement, it won't work! You have to call ExecSQL.

HTH


Leslie
landrews@metrocourt.state.nm.us

There are 10 types of people in the world -
those who understand binary
and
those who don't!
 
Hi again.

I am in a cottage in Norway.

TableCust and TableOrd: //se in the properties
Active := True;
AutoCalcFields := True;
AutoRefresh := True;
CachedUpdates := True;

Think it would help.. try it out...

I would also prefer wiz and lespaul way to handling database and queries...

cheers
mha
 
Sorry about last comments.. it did not help..

Got to take a further look...

mha
 
hi its me again.. :)

As I could remember there is also an example dbDates which is almost the same as the MastDet example...

Take a look at it..

Another thing are you using your own database and tables? Or are you using the dbdemos database example...

if so you should also see relations in that database tables..

cheers
mha
 
Table properties:
Active := True;
AutoCalcFields := True;

then you can post edit fields, but if you are trying to delete one field -> you will get msg -> master has no detailed record. can not delete or modify.

this I think is because of the table relations with other tables..

cheers,
mha
 
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! :)

Thanks to everyone who took an interest in my problem - and this great website!!


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