Page 1 of 1

Fwmariaconection class turn off messages

Posted: Wed Jun 05, 2019 2:28 pm
by audisys
Hello Mr Rao,

I'm doing tests with the Fwmariaconection class.
How do I control the error message of the connection and avoid the one generated by the class?
I turn off the Mariadb server and the error is interceded by the class and not the catch.

I connect like this

Code: Select all

TRY
      FWCONNECT oConect HOST "localhost:3307" USER "root" PASSWORD "mypass" DATABASE "gestion_ancla2018"
  CATCH oErr
      MsgStop("No es posible conectar con Servidor de Datos :"+oConect:nError )
      Return .f.
 END
 
Thank you for your cooperation,

Re: Fwmariaconection class turn off messages

Posted: Wed Jun 05, 2019 3:15 pm
by nageswaragunupudi
FWMarialib does not produce runtime errors for any server errors. So TRY/CATCH is not useful.

By default, only when an attempt to connect fails, the Library itself displays the error and returns nil, instead of connection object.
If the programmer does not want the library to display the error and display it himself, he may adopt this code:

Code: Select all

MsgRun( "Connecting", "MYSQL", { || oCn := maria_Connect( "localhost:3307", "gestion_ancla2018", "root", "mypass", .f. ) } )
if oCn == nil
   aError := maria_ConnectError()
   ? "Faied to connect" + CRLF + ;
     "Error No: " + Str( aError[ 1 ] ) + CRLF + ;
     "Error Msg: "  + aError[ 2 ]
   QUIT
else
   ? "Connected"
   // DO ANY WORK
   oCn:Close()
endif
 

Re: Fwmariaconection class turn off messages

Posted: Wed Jun 05, 2019 3:35 pm
by audisys
Perfect.

Thank You,