Code: Select all
#include "Fivewin.ch"
#include "tdolphin.ch"
#include "xbrowse.ch"
#include "slider.ch"
STATIC oDbf,oDlg,oSay,oGet,oBtn,oBmp,oWnd,oBrw,oError,oServer
STATIC oSlid
STATIC oFont,oFbold,oIcon
STATIC oRs,oCon,lOk,cCadena,oQry
STATIC cServer, cUser, cPassword, nPort, cDBName,nFlags,hIni,nServ
MEMVAR oP
REQUEST DBFCDX
///////////////////
Function Main()
local oSay[10],oBar,oIco,oMsg,oMsgOpe,cTitle
local oErr,nFld,n
// PUBLIC oP:=TVarPub()
SET DATE BRITISH
SET DELETED ON
SET EXCLUSIVE OFF
SET SOFTSEEK ON
SET WRAP ON
SET _3DLOOK ON
SET EPOCH TO YEAR(date()) - 50
SET MULTIPLE ON
SetHandleCount( 100 )
* BWCCRegister(Getresources())
SET RESOURCES TO "testmsql.dll"
RDDSetDefault( "DBFCDX" )
DEFINE ICON oIcon RESOURCE "system"
DEFINE FONT oFont NAME "MS SANS SERIF" SIZE 0,8
DEFINE FONT oFbold NAME "MS SANS SERIF" SIZE 0,8 BOLD
DEFINE BITMAP oBmp FILE "\testdol\senior.bmp"
* SetGetColorFocus(CLR_2)
* cHost:=Winexec("PING pharma-co.no-ip.org")
* ? cHost
cTitle:=" MySQL CONSULTAS"
DEFINE WINDOW oWnd FROM 8,30 TO 30,110 ;
TITLE cTitle ;
ICON oIco
DEFINE BUTTONBAR oBar OF oWnd 3D SIZE 40,40
DEFINE BUTTON RESOURCE "creden" OF oBar ;
ACTION (sound(),Conectar()) ;
FLAT ;
TOOLTIP OemToAnsi("Inicia la conexionn con el Servidor")
DEFINE BUTTON RESOURCE "stock" OF oBar ;
ACTION (sound()) ;
FLAT ;
TOOLTIP OemToAnsi("Consulta de Existencias"+CRLF+"y Precios de Productos")
DEFINE BUTTON RESOURCE "afiliados" OF oBar ;
ACTION (sound() ) ;
FLAT GROUP ;
TOOLTIP "Cuenta Corriente"+CRLF+"Saldo y Limite"
DEFINE BUTTON RESOURCE "cuentas" OF oBar ;
ACTION (sound()) ;
FLAT ;
TOOLTIP OemToAnsi("Cuenta Corriente"+CRLF+"Ultimos 10 Movimientos")
DEFINE BUTTON RESOURCE "phone" OF oBar ;
ACTION (sound()) ;
FLAT GROUP ;
TOOLTIP oemtoansi("ABM y Selecci¢n de IP para el FTP")
DEFINE BUTTON RESOURCE "tools" OF oBar ;
ACTION (sound()) ;
FLAT ;
TOOLTIP "Reordenamiento de Archivos"
DEFINE BUTTON RESOURCE "exit" OF oBar ;
ACTION (sound(),oWnd:end()) ;
FLAT GROUP ;
TOOLTIP OemToAnsi("SALIR")
SET MESSAGE OF oWnd TO "TESTDOLPHIN"
DEFINE MSGITEM oMsg SIZE 180 OF oWnd:oMsgBar FONT oFbold COLOR CLR_HRED
DEFINE MSGITEM oMsgOpe OF oWnd:oMsgBar SIZE 150 BITMAP "B_FACES","B_FACES" ;
PROMPT "OFF LINE " FONT oFbold
oWnd:oMsgBar:dateOn()
oWnd:oMsgBar:ClockOn()
oWnd:oFont := oFont
oWnd:bPainted := { | hDC | PalBmpDraw( hDC,0,0,oBmp:hBitmap ) }
ACTIVATE WINDOW oWnd
if(oServer != NIL)
oServer:end()
endif
dbcloseall()
set resources to
set 3dlook off
Release objects oFont,oFbold,oSlid
Sound()
return nil
//...............................
Function Conectar()
//..Identificador para el ini
local c:="mysql"
local oGet[7]
local cText,nFld
local nCount:=0
// hIni := HB_ReadIni( "testmsql.ini" )
oServer := NIL
cServer := "dolphintest.sitasoft.net" //hIni[ c ]["host"]
cUser := "test_dolphin" //hIni[ c ]["user"]
cPassword := "123456" //hIni[ c ]["psw"]
nPort := 3306 //val(hIni[ c ]["port"])
cDBName := "dolphin_man" //hIni[ c ]["dbname"]
nFlags := 0//val(hIni[ c ]["flags"])
nServ := "null" //val(hIni[ c ]["nServ"])
/*
DEFINE DIALOG oDlg RESOURCE "ServerConect"
REDEFINE BITMAP RESOURCE "pcvert" ID 4007 OF oDlg
REDEFINE GET oGet[1] VAR cServer ID 4008 OF oDlg UPDATE
REDEFINE GET oGet[2] VAR cUser ID 4009 OF oDlg UPDATE
REDEFINE GET oGet[3] VAR cPassword ID 4010 OF oDlg UPDATE
REDEFINE GET oGet[4] VAR nPort ID 4011 OF oDlg UPDATE
REDEFINE GET oGet[5] VAR cDbname ID 4012 OF oDlg UPDATE
REDEFINE GET oGet[6] VAR nFlags ID 4013 OF oDlg UPDATE
REDEFINE GET oGet[7] VAR nServ ID 4018 OF oDlg UPDATE
REDEFINE BUTTON ID 4015 OF oDlg ACTION (sound())
REDEFINE BUTTON ID 4016 OF oDlg ACTION (sound(),oDlg:end()) // sale del oDlg y se conecta -->
ACTIVATE DIALOG oDlg CENTERED
*/
TRY
CONNECT oServer HOST cServer ;
USER cUser ;
PASSWORD cPassword ;
PORT nPort ;
FLAGS nFlags;
DATABASE cDBName
CATCH oErr
msgInfo("Se ha producido un error"+CRLF+;
"en la conexion con el Servidor"+CRLF+;
"Reintente...","Error de Conexion...")
RETURN NIL
END
IF !oServer:lError
cText :=""
cText += "Conexion OK" + CRLF
cText += "Host: " + oServer:cHost +CRLF
cText += "Database: " +oServer:cDBName + CRLF
cText += oServer:GetServerInfo() + CRLF
cText += oServer:GetClientInfo() + CRLF
MsgInfo( cText,"informacion...")
ENDIF
oQry = TDolphinQry():New( "SELECT first_name,Last_name FROM president", oServer )
nFld := oQry:FCount() // Total de campos
While !oQry:EOF()
nCount++
? oQry:First_name, oQry:Last_name
oQry:skip()
if nCount >= 10
exit
endif
Enddo
///// HACE TODO EL QUERY Y ME MUESTRA LOS REGISTROS SIN PROBLEMAS
oQry:end()
oServer:end()
//// CUANDO TERMINA LA FUNCION Y RETORNA A LA VENTANA DE INICIO SE PRODUCE EL ERROR Y SE CUELGA TODO
RETURN NIL
//..............
FUNCTION sound()
SndPlaySound("click.wav")
Return Nil