locked
Mysql connector / Myodbc - how to trap pause errors withing foxpro RRS feed

  • Question

  • Ok, this one may not be purely foxpro but I wanted to ask how people in the community who use Mysql solve this.

    I connect to a remote Mysql database. I have the Myodbc drivers installed on a win 2012 server, and I have a form with a timer which triggers some sql procedure. It runs great, but:

    Once in a while, probably because of failure to connect, the Myodbc/Mysql connector window pops up and pauses the execution of the entire program. Once a user presses enter, the program continues to run.

    How would one eliminate that window popping up and pausing the whole thing?

    Thanks.

    Friday, December 28, 2018 2:44 AM

Answers

  • SQLSetProp(0,"DispLogin",3)
    SQLSetProp(0,"DispWarnings",.f.)

    I didn't do a repro of the problem, but actually DispWarnings should be the setting suppressing such warnings and is .f. by default. Login dialogs should only display, if credentials are missing or wrong.

    These settings should be done before you even make your first connection, the 0 specified for the connectoin handle works quite like 0 works for workarea 0 in CursorSetProp() calls to set a default for all workareas, here it causes that as default for any connection.

    Notice failing logins or warnings then cause the ODBC error and so you then need to put SQLStringConnect into a TRY..CATCH block or handle ODBC errors in some way in your general error handler or an error method (of the timer).

    Bye, Olaf.


    • Marked as answer by Aleniko2 Friday, December 28, 2018 2:11 PM
    • Edited by OlafDoschke Friday, December 28, 2018 3:05 PM
    Friday, December 28, 2018 9:26 AM

All replies

  • SQLSetProp(0,"DispLogin",3)
    SQLSetProp(0,"DispWarnings",.f.)

    I didn't do a repro of the problem, but actually DispWarnings should be the setting suppressing such warnings and is .f. by default. Login dialogs should only display, if credentials are missing or wrong.

    These settings should be done before you even make your first connection, the 0 specified for the connectoin handle works quite like 0 works for workarea 0 in CursorSetProp() calls to set a default for all workareas, here it causes that as default for any connection.

    Notice failing logins or warnings then cause the ODBC error and so you then need to put SQLStringConnect into a TRY..CATCH block or handle ODBC errors in some way in your general error handler or an error method (of the timer).

    Bye, Olaf.


    • Marked as answer by Aleniko2 Friday, December 28, 2018 2:11 PM
    • Edited by OlafDoschke Friday, December 28, 2018 3:05 PM
    Friday, December 28, 2018 9:26 AM
  • Olaf;

    As always, you are a godsend.

    Thank you so much.

    Friday, December 28, 2018 2:11 PM