#include "fivewin.ch"
Static oServer
Function Main
oServer := connect()
If CheckConect()
?"EXISTE CONEXION AL SERVIDOR"
Endif
OServer:End()
Return nil
Static Function Connect
LOCAL oServer
LOCAL cServer, cUser, cPassword, cDBName
cServer := GetPvProfString("mysql","host" ," " ,".\connect.ini")
cUser := GetPvProfString("mysql","user" ," " ,".\connect.ini")
cPassword := GetPvProfString("mysql","psw" ," " ,".\connect.ini")
cDBName := GetPvProfString("mysql","dbname" ," " ,".\connect.ini")
// abrimos la conexion
TRY
FWCONNECT oServer HOST cServer ;
USER cUser ;
PASSWORD cPassword ;
DATABASE cDBName
CATCH oErr
oServer:ShowError()
END
Return oServer
Function CheckConect
local IsQry,aWait
local lConn:= .T.
Try
if oServer:ping()
IsQry := oServer:Query("Select 1 AS num")
IsQry:End()
Else
lConn := .F.
Endif
Catch o
Try
oServer:ReConnect()
SysRefresh()
Catch e
lConn := .F.
oServer:Showerror()
End
End
return lConn
#include "fivewin.ch"
Static oServer
Function Main
local owait
WaitOn("Espere un momento....",@oWait )
HB_GCALL( .F. )
oServer := connect()
If CheckConect()
?"A1"
WaitOff( @oWait )
?"A2"
?"EXISTE CONEXION AL SERVIDOR"
Endif
OServer:End()
Return nil
Static Function Connect
LOCAL oServer
LOCAL cServer, cUser, cPassword, cDBName
cServer := GetPvProfString("mysql","host" ," " ,".\connect.ini")
cUser := GetPvProfString("mysql","user" ," " ,".\connect.ini")
cPassword := GetPvProfString("mysql","psw" ," " ,".\connect.ini")
cDBName := GetPvProfString("mysql","dbname" ," " ,".\connect.ini")
// abrimos la conexion
TRY
FWCONNECT oServer HOST cServer ;
USER cUser ;
PASSWORD cPassword ;
DATABASE cDBName
CATCH oErr
oServer:ShowError()
END
Return oServer
Function CheckConect
local IsQry,aWait
local lConn:= .T.
Try
if oServer:ping()
IsQry := oServer:Query("Select 1 AS num")
IsQry:End()
Else
lConn := .F.
Endif
Catch o
Try
oServer:ReConnect()
SysRefresh()
Catch e
lConn := .F.
oServer:Showerror()
End
End
return lConn
function waitOn( cCaption, oWait, cTitle ) //simula un waiton de grump
LOCAL nWidth
local lVal := .t.
local oBrush
local oImage, lSetAlpha := .t.
local bAction := { || .t. }
default cTitle := "Usuario, un momento por favor"
DEFINE BRUSH oBrush COLOR RGB( 192, 216, 255 ) //rosa
IF cCaption == NIL
DEFINE DIALOG oWait ;
FROM 0,0 TO 5, Len( cTitle ) + 4 ;
STYLE nOr( DS_MODALFRAME, WS_POPUP ) TRANSPARENT //BRUSH oBrush
ELSE
DEFINE DIALOG oWait ;
FROM 0,0 TO 6, Max( Len( cCaption ), Len( cTitle ) ) + 4 ;
TITLE cTitle ;
STYLE DS_MODALFRAME TRANSPARENT //BRUSH oBrush
ENDIF
oWait:cMsg := cCaption
nWidth := oWait:nRight - oWait:nLeft
ACTIVATE DIALOG oWait CENTER ;
ON PAINT oWait:Say( 1, 0, xPadC( oWait:cMsg, nWidth ) ) ;
NOWAIT
SysRefresh()
return (lVal)
//------------------------------------------------------------------------------
function WaitOff( oWait )
IF valtype(oWait) != 'U' /* waiton has to be called first! */
oWait:end()
oWait := NIL
ENDIF
sysRefresh()
RETURN NIL
#include "fivewin.ch"
Static oServer
Function Main
local owait
WaitOn("Espere un momento....",@oWait )
HB_GCALL( .F. )
oServer := connect()
If CheckConect()
?"A1"
WaitOff( @oWait )
?"A2"
?"EXISTE CONEXION AL SERVIDOR"
Endif
OServer:End()
Return nil
Static Function Connect
LOCAL oServer,o
LOCAL cServer, cUser, cPassword, cDBName
cServer := GetPvProfString("mysql","host" ," " ,".\connect.ini")
cUser := GetPvProfString("mysql","user" ," " ,".\connect.ini")
cPassword := GetPvProfString("mysql","psw" ," " ,".\connect.ini")
cDBName := GetPvProfString("mysql","dbname" ," " ,".\connect.ini")
// abrimos la conexion
TRY
FWCONNECT oServer HOST cServer ;
USER cUser ;
PASSWORD cPassword ;
DATABASE cDBName
CATCH o
oServer:ShowError()
END
Return oServer
Function CheckConect
local IsQry,aWait,o,e
local lConn:= .T.
Try
if oServer:ping()
IsQry := oServer:QueryResult("Select 1 AS num")
*IsQry:End()
Else
lConn := .F.
Endif
Catch o
Try
oServer:ReConnect()
SysRefresh()
Catch e
lConn := .F.
oServer:Showerror()
End
End
return lConn
function waitOn( cCaption, oWait, cTitle ) //simula un waiton de grump
LOCAL nWidth
local lVal := .t.
local oBrush
local oImage, lSetAlpha := .t.
local bAction := { || .t. }
default cTitle := "Usuario, un momento por favor"
DEFINE BRUSH oBrush COLOR RGB( 192, 216, 255 ) //rosa
IF cCaption == NIL
DEFINE DIALOG oWait ;
FROM 0,0 TO 5, Len( cTitle ) + 4 ;
STYLE nOr( DS_MODALFRAME, WS_POPUP ) TRANSPARENT //BRUSH oBrush
ELSE
DEFINE DIALOG oWait ;
FROM 0,0 TO 6, Max( Len( cCaption ), Len( cTitle ) ) + 4 ;
TITLE cTitle ;
STYLE DS_MODALFRAME TRANSPARENT //BRUSH oBrush
ENDIF
oWait:cMsg := cCaption
nWidth := oWait:nRight - oWait:nLeft
ACTIVATE DIALOG oWait CENTER ;
ON PAINT oWait:Say( 1, 0, xPadC( oWait:cMsg, nWidth ) ) ;
NOWAIT
SysRefresh()
return (lVal)
//------------------------------------------------------------------------------
function WaitOff( oWait )
IF valtype(oWait) != 'U' /* waiton has to be called first! */
?"ANTES DE FALLAR"
oWait:end()
oWait := NIL
ENDIF
sysRefresh()
RETURN NIL
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: Google [Bot] and 10 guests