1 (edited by thezimguy 2018-08-22 16:44:08)

Topic: OnSQLException - Control MySQL Errors

Hello Dmitry and MVD Lovers,

https://s6.postimg.cc/d0ct0824h/EXCEPTION.png

I'm using the following function provided by Dmitry to control error message on MySQL Connection and Queries.
It works fine but at the second attempt it starts again with the system error messages.
Any Help?

function OnSQLException(Sender: TObject; Msg: string; SQL: string): boolean;
begin

    // how to catch lost connection for MySQL
    if Pos('Lost connection to MySQL server during query', Msg)=1 then
    //if Pos('Lost connection to MySQL server during query', Msg)=1 then
    begin
        result := True; // to prevent system message
        // Own message
        MessageBox('Lost connection. Please try again.', 'Error', MB_OK+MB_ICONWARNING);
    end;

end;

Thanks

@thezimguy

Re: OnSQLException - Control MySQL Errors

Also is there an example with the following?

SET SESSION wait_timeout = 999999;

Tnx

@thezimguy

Re: OnSQLException - Control MySQL Errors

SQLExecute('SET SESSION wait_timeout = 999999');
Dmitry.

Re: OnSQLException - Control MySQL Errors

OnSQLException
Please can I get detailed examples on
OnSQLException
Thank you

@thezimguy

Re: OnSQLException - Control MySQL Errors

What do you mean detailed?

Dmitry.