Page 1 of 1
Try-Except vs OnError for MyConnection and MyQuery
Posted: Fri 04 Mar 2005 14:30
by TheLion
Hi
Running MyDAC v3.50.0.16 with Delphi 5 on MySQL 4.0.23-classic
I have a problem with getting a error message out of my program, for a simple Select statement that fails.
None of the OnError events cath the fault. It does get trapped into the Except-End loop. Is there any why I can get an error message from within that loop?
Btw. if I copy the Select statement from my errorlog and paste it in the query browser it works!!!
Posted: Sat 05 Mar 2005 14:01
by Ikar
OnError determines type of the exception that will be generated on error (EMyError or EAbort). In both cases to handle errors in the queries you need try..except block.
> Btw. if I copy the Select statement from my errorlog and paste it in the query
> browser it works!!!
Please send us complete small sample to demonstrate it and include script to create server objects.
Posted: Sat 05 Mar 2005 14:32
by TheLion
Hi
I have a Try Except block. But how do I get an error txt string from inside this block. I need that to save it to my Log, so I can see what goes wrong.
In the different OnError... events I have EDAError or EDatabaseError and can get an error text message from that type. My Question is how do I get an error text from within the Try Except block.
My Main program works on 2 servers, but not on the 3th one. If I make a small sample program, that works on all 3 servers!!! I have to find out what is wrong. Normally any errors get trapped in an OnError... event for either MyConnection or MyQuery. But this one only get to the Except-End part of the Try Except block!!!
I use these onerror methods.
Code: Select all
MyQuery.Connection.OnError
MyQuery.OnDeleteError
MyQuery.OnEditError
MyQuery.OnPostError
MyQuery.OnUpdateError
Posted: Wed 09 Mar 2005 15:44
by Ikar
> how do I get an error text from within the Try Except block.
You should use the next construction:
Code: Select all
try
except
on e: EMyError do begin
...
end;
end;
Posted: Wed 09 Mar 2005 16:07
by TheLion
Hi
Thats way to simple

Why didn't I think of that!!!!
That will solve my problem
Thank you
