Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 1 to 10 of 11 total |
Override OnDeleteError Event |
Tue, Jul 22 2008 7:10 AM | Permanent Link |
Thomas H. Grimm | Hi,
i am trying this: type TMPVTable = class(TDBISAMTable) private { Private-Deklarationen } protected procedure DeleteError; override; public { Public-Deklarationen } published end; procedure Register; implementation procedure Register; begin RegisterComponents('DBISAM', [TMPVTable]); end; procedure TMPVTable.DeleteError(DataSet: TDataSet; E: EDatabaseError; var Action: TDataAction); begin ... end; but in line procedure DeleteError; override; i get a compiler error that says that this methode is not included in base class. After a long study of the online help for hirachie and the vcl sources i cant find the mistake. background: i want implement some code for the events PostError, EditError, DeleteError in a new table component In this case i am using DBISAM V2.12 std and D5#1 thanx for reading |
Tue, Jul 22 2008 11:54 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Thomas,
<< i get a compiler error that says that this methode is not included in base class. After a long study of the online help for hirachie and the vcl sources i cant find the mistake. >> The mistake is exactly as the compiler states - there is no DeleteError method in the base TDataSet class. There is an *event* called OnDeleteError, but you can't override events. Your best bet is to override the InternalDelete method like this: protected procedure InternalDelete; override; end; procedure TMPVTable.InternalDelete; begin try inherited InternalDelete; except // Do error handling here end; end; You can do the same thing for InternalEdit, InternalCancel, InternalPost, etc. Just be sure to always call the inherited functionality. -- Tim Young Elevate Software www.elevatesoft.com |
Tue, Jul 22 2008 12:56 PM | Permanent Link |
Thomas H. Grimm | Dear Tim,
"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote: <<The mistake is exactly as the compiler states - there is no DeleteError method in the base TDataSet class. There is an *event* called OnDeleteError, but you can't override events.>> first of all i am not experienced with component development. now i am a little confused. i have a tutor book for delphi, it is a besteller her in germany. there is a chapter about component development called "Overriding standard events". there is said you can override events methods. it is follwed by a small example. type TBeepEdit = class(TEdit) protected procedure Keypress(var key:char); override; end; procedure TBeepEdit.Keypress(Key); begin inherited KeyPress(key); beep; end; this example works. so what is the difference in this example and my approach to overide the OnDeleteError Event? What have i missed? <<Your best bet is to override the InternalDelete method like this: protected procedure InternalDelete; override; end; procedure TMPVTable.InternalDelete; begin try inherited InternalDelete; except // Do error handling here end; end; You can do the same thing for InternalEdit, InternalCancel, InternalPost, etc. Just be sure to always call the inherited functionality.>> i will try this. but it is mostly said not to use such internal procedures. what do you say in general about your example good or bad approach? thanx for reading and answering. Thomas H. Grimm |
Tue, Jul 22 2008 1:31 PM | Permanent Link |
Eryk Bottomley | Thomas H. Grimm wrote:
> this example works. so what is the difference in this example and my approach to overide > the OnDeleteError Event? > What have i missed? There happens to be a KeyPress procedure that corresponds to the OnKeyPress property while there is no DeleteError procedure corresponding to the OnDeleteError property. The compiler does not infer any relationship between "property OnKeyPress" and "procedure KeyPress" based on the name - this is just a convention adopted by the programmer. Other common conventions that have no meaning to the compiler include starting all fields with the letter "F" and starting the procedures and functions that implement properties with "Get" and "Set". Just because there is a "property This" one cannot assume that "function GetThis", "procedure SetThis" and "FThis" necessarily exist. > i will try this. but it is mostly said not to use such internal procedures. "Internal" is just another naming convention adopted by whoever wrote the original code - it has no defined meaning. If something is not meant to be overridden then it should be registered as "private" in the base class. Anything registered as "protected" is specifically intended to be overridden. Eryk |
Wed, Jul 23 2008 5:40 AM | Permanent Link |
Thomas H. Grimm | hi Eryk,
<<"Internal" is just another naming convention adopted by whoever wrote the original code - it has no defined meaning. If something is not meant to be overridden then it should be registered as "private" in the base class. Anything registered as "protected" is specifically intended to be overridden.>> i know that these are only conventions. but if one chooses such a name he will not do this without any reason, i think. so i am unsure if, in some circumstances, the use of such procedure isn't problematic. perhabs may fault. But thank you for answer. The support always was and is a big point for elevate. |
Wed, Jul 23 2008 5:55 AM | Permanent Link |
Thomas H. Grimm | Hi,
<<procedure TMPVTable.InternalDelete; begin try inherited InternalDelete; except // Do error handling here end; end;>> so far no problem, but my error handling code looks like this if (E is EDBISAMEngineError) and (EDBISAMEngineError(E).Errors[0].ErrorCode = DBISAM_RECLOCKFAILED) then begin if (MessageDlg('fmDeleteErrorLocked', mtWarning,[mbYes,mbNo],0)=mrYes) then Action:=daRetry else begin Action:=daAbort; end; end else begin MessageDlg(E.Message,mtError,[mbOk],0); Action:=daAbort; end; it is taken from my current OnDeleteError event i use in so much cases. in your solution, where i get the Value of E from? And how to handle the Abort or Retry statements? i only have the dbisam std, so no sources i can investigate. tanhx for reading and answering. |
Wed, Jul 23 2008 7:33 AM | Permanent Link |
Rolf Frei eicom GmbH | Below you can see how you can get an ExceptionObject variable E. The Event
Variable "Action" isn't usable here in this methode. So you must do something similar to the TDataset.CheckOpertation Methode like this: procedure TMPVTable.InternalDelete; var Done: Boolean; begin Done := False; repeat try inherited InternalDelete; Done := True; except // Do error handling here on E: EDBISAMEngineError do begin if (EDBISAMEngineError(E).Errors[0].ErrorCode = DBISAM_RECLOCKFAILED) then begin if (MessageDlg('fmDeleteErrorLocked', mtWarning,[mbYes,mbNo],0)<>mrYes) then SysUtils.Abort; end else raise; end on E: Exception do begin MessageDlg(E.Message,mtError,[mbOk],0); SysUtils.Abort end; end; until Done; end; "Thomas H. Grimm" <tgrim01@web.de> schrieb im Newsbeitrag news:5C4BF6C9-7490-422C-BD55-783D09E78BF6@news.elevatesoft.com... > Hi, > > > <<procedure TMPVTable.InternalDelete; > begin > try > inherited InternalDelete; > except > // Do error handling here > end; > end;>> > > so far no problem, but my error handling code looks like this > > if (E is EDBISAMEngineError) and > (EDBISAMEngineError(E).Errors[0].ErrorCode = DBISAM_RECLOCKFAILED) > then > begin > if (MessageDlg('fmDeleteErrorLocked', > mtWarning,[mbYes,mbNo],0)=mrYes) then > Action:=daRetry > else > begin > Action:=daAbort; > end; > end > else > begin > MessageDlg(E.Message,mtError,[mbOk],0); > Action:=daAbort; > end; > > it is taken from my current OnDeleteError event i use in so much cases. in > your solution, > where i get the Value of E from? And how to handle the Abort or Retry > statements? i only > have the dbisam std, so no sources i can investigate. > > tanhx for reading and answering. > |
Wed, Jul 23 2008 9:37 AM | Permanent Link |
Thomas H. Grimm | thank you Rolf. works like expected
Are you from switzerland? What means "Team Elevate"? "Rolf Frei [Team Elevate]" <rolf@eicom.ch> wrote: Below you can see how you can get an ExceptionObject variable E. The Event Variable "Action" isn't usable here in this methode. So you must do something similar to the TDataset.CheckOpertation Methode like this: |
Wed, Jul 23 2008 9:53 AM | Permanent Link |
Eryk Bottomley | Thomas,
> i know that these are only conventions. but if one chooses such a name he will not do this > without any reason, i think. so i am unsure if, in some circumstances, the use of such > procedure isn't problematic. perhabs may fault. If the developer didn't want you to override a method he would make it "private" to prevent you doing so. This is why "private" exists. Making a method "protected" specifically invites people to override the base functionality. Eryk |
Wed, Jul 23 2008 10:12 AM | Permanent Link |
Rolf Frei eicom GmbH | Yes I'm from Switzerland. I'm a Volunteer for Elevatesoft which helps to
answer questions about DBIISMA 2/3 here in this forum. All this Volunteers have the addition of "[Team Elevate]" in the name. "Thomas H. Grimm" <tgrim01@web.de> schrieb im Newsbeitrag news:1ECCD67B-B253-4F34-B1DC-1DEC0C5809C7@news.elevatesoft.com... > thank you Rolf. works like expected > > Are you from switzerland? > What means "Team Elevate"? > > "Rolf Frei [Team Elevate]" <rolf@eicom.ch> wrote: > > Below you can see how you can get an ExceptionObject variable E. The Event > Variable "Action" isn't usable here in this methode. So you must do > something similar to the TDataset.CheckOpertation Methode like this: > |
Page 1 of 2 | Next Page » | |
Jump to Page: 1 2 |
This web page was last updated on Friday, April 19, 2024 at 07:09 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |