Fwmariaconection class turn off messages

Fwmariaconection class turn off messages

Postby audisys » Wed Jun 05, 2019 2:28 pm

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  Expand view
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,
José David Angulo
Auditoria y Sitemas Ltda.
Cartagena Colombia
audisys
 
Posts: 49
Joined: Wed Apr 18, 2007 6:01 pm
Location: Cartagena - Colombia

Re: Fwmariaconection class turn off messages

Postby nageswaragunupudi » Wed Jun 05, 2019 3:15 pm

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  Expand view
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
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Fwmariaconection class turn off messages

Postby audisys » Wed Jun 05, 2019 3:35 pm

Perfect.

Thank You,
José David Angulo
Auditoria y Sitemas Ltda.
Cartagena Colombia
audisys
 
Posts: 49
Joined: Wed Apr 18, 2007 6:01 pm
Location: Cartagena - Colombia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 49 guests