Board index » delphi » TQuery's OnEditError not Firing for SQL INSERT Errors

TQuery's OnEditError not Firing for SQL INSERT Errors

I'm using BCB v5.0 with the patch...
I setup a TQuery with the strings property set to

INSERT INTO
tbl_Customers (WWID, FirstName, LastName, WorkPhone)
VALUES (:WWID, :FirstName, :LastName, :WorkPhone)

The "WWID" is the primary key.
I then deliberately config'ed the params to have a duplicate primary key
value.  I then created the OnEditError function to show a message and set
the action = daAbort.
From an TButton OnClick event I called the Query's ExecSQL() function.  The
OnEditError never fires.
I also set Request Live to false.  Shouldn't the OnEditError fire... or did
I miss something?

 

Re:TQuery's OnEditError not Firing for SQL INSERT Errors


No. OnEditError only fires when RequestLive is true and you are editing by
placing the query in Edit mode, making changes and calling Post.

--
Bill

Re:TQuery's OnEditError not Firing for SQL INSERT Errors


Hey Bill,
Thanks again... I'm getting closer and closer to clear picture.... and your
response leads me to my next question...
Is there an event procedure for errors that happen when the following are
used together?
- TQuery.ExecSQL() method
- SQL string "INSERT INTO ..."
- RequestLive = false

If there is no event procedure for the above then I assume that I must
trap/respond to exceptions the c++ way with try/catch blocks.
I'm gonna fire away a few more quick questions...
(A)  What can I expect to happen when the following conditions hold true?
        -  use the TQuery.ExecSQL() method, and RequestLive = false
        - SQL strings of UPDATE, DELETE, and CREATE TABLE (the other action
queries)

(B)  Will these guys fire when the conditions for question (A) hold true?
    - OnUpdateError()
    - OnDeleteError()
    - OnPostError()

and my last question...
(C)  What exception classes will be thrown when the conditions for question
(A) hold true?
        - EDatabaseError only
        - EDBEngineError only
        - A mix of the two
        - Other exception class(es)

"Bill Todd (TeamB)" <billtodd...@nospam.qwest.net> wrote in message
news:3a92a0b9_1@dnews...

Quote
> No. OnEditError only fires when RequestLive is true and you are editing by
> placing the query in Edit mode, making changes and calling Post.

> --
> Bill

Re:TQuery's OnEditError not Firing for SQL INSERT Errors


Is there an event procedure for errors that happen when the following are
used together?
- TQuery.ExecSQL() method
- SQL string "INSERT INTO ..."
- RequestLive = false

Quote
>>No. You have to use try/catch or try/except (depending on whether you are

using C++ or Delphi).

B)  Will these guys fire when the conditions for question (A) hold true?
    - OnUpdateError()
    - OnDeleteError()
    - OnPostError()

Quote
>>No. Use try/except around the call to ExecSQL.

(C)  What exception classes will be thrown when the conditions for question
(A) hold true?
        - EDatabaseError only
        - EDBEngineError only
        - A mix of the two
        - Other exception class(es)

Quote
>>EDatabaseError and its descendents (which includes EDBEngineError).

--
Bill

Other Threads