Board index » delphi » OnPostError Event problems

OnPostError Event problems

I am trying to use the OnPostError Event on a TTable.  However when I do
a Post on a TTable, an exception is raised because I do not have a value
in a required field (just as I wanted, so I could test it).  However I
am trying to resolve the problem in the event OnPostError.
Unfortunately it does not ever call this event but the exception is
raised.  I have tried it with and without cached updates, and with
Oracle and Paradox.  They all have the same reaction (they raise the
exception on the TTable1.post but dont hit the event).  I get no errors
writing the data between the two ttables and I am not working with any
Tfields so I cant use the OnValidate.  But it is definately on the
Post.  Any ideas? (using Delphi 4)
 

Re:OnPostError Event problems


Searching Deja.com, I found someone else complaining
about the same problem but they received no response.
Someone else had trouble using the event, and a very
smart person Jan Sprengers posted some
code:

procedure Table1PostError(DataSet: TDataSet; E: EDatabaseError;   var
Action: TDataAction);
var
    ErrCode: DBIResult;
begin
    ErrCode := 0;
    if E is EDBEngineError then
        with EDBEngineError(E) do
            ErrCode := Errors[ErrorCount-1].ErrorCode;
    if ErrCode = DBIERR_KEYVIOL then
    begin
      <handle the error>
    end else
        Action := daFail;
end;

I normally use the beforepost event to validate things
so I don't know for sure what your problem is.  My
suspicion is that you are hitting what I consider
a major defect in Paradox files/BDE required values.
The bde dies on required values and sends
the exception to delphi at the wrong event.  It also can manifest
itself when attempting to use cached updates
in combination with default values and required fields.
The bde vomits on the required field before filling
in the default values.  My solution is  to NEVER
MARK any field as required in Paradox format files.
Unfortunately, that means you cannot take advantage
of the very feature you are now trying to use.  By
the way, I'm still using BDE 4.51.  Maybe this is fixed
in BDE5.  To summarize, then, required fields in Paradox
files don't work properly because the exception comes too
early as you now know.

Quote
Kathy Calvert <calve...@gnt.net> wrote in message

news:380A6F49.D7BBA1B1@gnt.net...
Quote
> I am trying to use the OnPostError Event on a TTable.  However when I do
> a Post on a TTable, an exception is raised because I do not have a value
> in a required field (just as I wanted, so I could test it).  However I
> am trying to resolve the problem in the event OnPostError.
> Unfortunately it does not ever call this event but the exception is
> raised.  I have tried it with and without cached updates, and with
> Oracle and Paradox.  They all have the same reaction (they raise the
> exception on the TTable1.post but dont hit the event).  I get no errors
> writing the data between the two ttables and I am not working with any
> Tfields so I cant use the OnValidate.  But it is definately on the
> Post.  Any ideas? (using Delphi 4)

Other Threads