Estoy con un tema que me tiene frito, no soy capaz de encontrar un dato mediante ADORDD en una tabla, siempre me da algun tipo de error, o simplemente no lo busca.
Tengo el siguiente codigo completo:
Code: Select all
** ************************************
** ------------------------------------
** RUTINAS PARA LA GESTION DE Avisos
** ------------------------------------
** ************************************
#include "adordd.ch"
#include "FiveWin.ch"
#include "Report.ch"
#include "dtpicker.ch"
#include "ord.ch"
#include "calendar.ch"
#include "xbrowse.ch"
#include 'hbcompat.ch'
STATIC oReport
//-----------------------------------------
memvar Publicas
memvar ccomentario
memvar cincidencia
memvar cruta
memvar ccodpro
memvar cpro1
memvar cdomi1
memvar ctel1
FUNCTION Paginaweb()
local cTitulo
cTitulo:="Trato de albaranes en pagina web"
Publicas:cserver1:="Localhost"
Publicas:cUser1 :="root"
Publicas:cPassword1""
Publicas:cPuerto:="3306"
Publicas:cBase:="Base"
Publicas:cTabla:="podwin"
//-------------------
trataweb(cTitulo)
return nil
//-------------------
///////////// AVISOS EN INTERNET
static function trataweb(ctitulo)
local oDlg, oLbx,oBrw
LOCAL oServer
LOCAL oRs
local hdc :=CreateDc("DISPLAY","","")
local nHor:=GetDeviceCaps(hdc,8)
local nVer:=GetDeviceCaps(hdc,10)
local x1:=30
local y1:=30
local x2:=nver-160
local y2:=nHor-30
local oBar
IF ( oServer := ConectaP() ) != NIL
oRS = PodSet( oServer )
DEFINE WINDOW oDlg MDICHILD ICON Publicas:oIco;
OF Publicas:oWPpal;
FROM x1,y1;
TO x2,y2;
COLOR CLR_BLACK,CLR_WHITE;
PIXEL
oDlg:cTitle:=cTitulo
DEFINE BUTTONBAR oBar TOP 3D OF oDlg
DEFINE BUTTON RESOURCE "CAMBIA" OF oBar NOBORDER MESSAGE "Subir Imagenes" ACTION (Subeimagen(oServer,oRs,oBrw),oDlg:Refresh());
TOOLTIP "Subir Imagenes escaneadas"
DEFINE BUTTON RESOURCE "SALIR" OF oBar NOBORDER MESSAGE "Salir" ACTION oDlg:END();
TOOLTIP "Salir"
@ 0, 0 xbrowse oBrw object oRS ;
COLUMNS "no_pedido","no_manif","Fecha" ,"Fechapod" ,"horapod" ,"webacces1" ,"Compania","Origen","Destino","Imagen","Importe","Segmer","Bultos" ;
HEADERS "Orden" ,"Albaran" ,"Fecha" ,"Fecha_ega" ,"Hora_ega" ,"Codigo" ,"Nombre" ,"Origen","Destino","Imagen","Importe","Refa" ,"Bultos" ;
COLSIZES 100,60,60,60,60,80,250,250,250,20,60,150,40 ;
AUTOCOLS LINES CELL
oBrw:lColDividerComplete:= .f.
oBrw:nTop := oDlg:nTop()
oBrw:lKineticBrw := .f.
oBrw:nMarqueeStyle := MARQSTYLE_HIGHLROW // Con cursor de todo el renglón
oBrw:nBottom := 152
oBrw:nRight := oDlg:nWidth()
oBrw:nStretchCol := STRETCHCOL_LAST
oBrw:CreateFromCode()
oDlg:oClient = oBrw
ACTIVATE WINDOW oDlg ;
ON INIT oBrw:SetFocus() ;
MAXIMIZED;
ON RESIZE (oBrw:nWidth:=oDlg:nWidth-10,;
oBrw:nHeight:=oDlg:nHeight-95,;
oBrw:Refresh());
VALID (oBrw:Close(),.t. )
ENDIF
return nil
////-------------DESCARGA DE INTERNET
///////////////////////////////////
FUNCTION PodSet( oServer )
LOCAL oRS, oError, cQry,cCant
TRY
oRS = CreateObject( "ADODB.RecordSet" )
CATCH oError
? "Ha fallado el inicio!!!"
ShowError( oError )
RETURN NIL
END
cQry = "SELECT NO_PEDIDO,NO_MANIF,FECHA,FECHAPOD,FIRMAPOD,HORAPOD,WEBACCES1,COMPANIA,ORIGEN,DESTINO,IMAGEN,IMPORTE,SEGMER,BULTOS FROM podwin ORDER BY no_pedido"
oRS:cursorLocation = adUseClient
oRS:lockType = adLockOptimistic
oRS:cursorType = adOpenDynamic
oRS:source = cQry
oRS:activeConnection = oServer
TRY
oRS:open()
CATCH oError
? "Ha fallado la orden de seleccion!!!"
ShowError( oError )
RETURN NIL
END
return oRS
//-----------------------------------------//
FUNCTION ConecTaP()
LOCAL oServer := NIL
LOCAL cServer:=Publicas:cserver1
LOCAL cUser :=Publicas:cUser1
LOCAL cPassword :=Publicas:cPassword1
LOCAL nPort
LOCAL cDBName
LOCAL nFlags
LOCAL oErr
LOCAL cConString
LOCAL lRet := .T.
LOCAL cTable
nPort := Publicas:cPuerto
cDBName := Publicas:cBase
cTable := Publicas:cTabla
nFlags := 0
cConString := "Driver={MySQL ODBC 5.1 Driver}" + ;
";Server=" + cServer + ;
";DefaultDatabase=" + cDBName + ;
";Database=" + cDBName + ;
";Port=" + nPort + ;
";User=" + cUser + ;
";Password=" + cPassword + ;
";Option=3;"
TRY
oServer := CreateObject( "ADODB.Connection" )
CATCH oErr
? "Ha fallado el inicio del Servidor!!!"
ShowError( oErr )
RETURN NIL
END
oServer:ConnecTionString := cConString
TRY
oServer:Open()
CATCH oErr
? "Ha fallado la conexion con el servidor!!!"
ShowError( oErr )
RETURN NIL
END
RETURN oServer
//-----------------------------------------
Static function subeimagen(oServer,oRs,oBrw)
local oDlg,i,osay,oini,ofin,oboton,oboton1
local continua:=.F.
local aAlias
local cIni:= Date()
local cFin:= Date()
local norden,cAwb,cFile
aAlias:= cargaAlias()
dbUseArea(.T.,,Publicas:cUnidad+Publicas:cSubd+"\ALBARAN",aAlias[24],.T.)
(aAlias[24])->(OrdSetFocus("Fecha"))
(aAlias[24])->( dbGotop() )
DEFINE DIALOG oDlg RESOURCE "DESDE" BRUSH Publicas:oBrush1 TRANSPARENT Font Publicas:oWPpal:ofont
for i = 10 to 11
REDEFINE SAY osay ID i OF oDlg COLOR CLR_GREEN
next i
REDEFINE Dtpicker oini VAR cIni ID 101 OF oDlg
REDEFINE Dtpicker ofin VAR cFin ID 102 OF oDlg
REDEFINE BUTTON oboton ID 550 OF oDlg PROMPT "Aceptar" ;
ACTION (Continua := .T., oDlg:End())
REDEFINE BUTTON oboton1 ID 551 OF oDlg PROMPT "Cancelar" ;
ACTION (oDlg:End()) CANCEL
ACTIVATE DIALOG oDlg CENTERED
if Continua
(aAlias[24])->(Ordscope(0,cIni))
(aAlias[24])->(Ordscope(1,cFin))
(aAlias[24])->(Dbgotop())
do while !(aAlias[24])->(Eof())
norden:=alltrim(str((aAlias[24])->Orden,7))
cAwb:=PADL(norden,7,"0")
cFile:=Publicas:cDocs+cAwb+".JPG"
IF FILE(cFile)
oRs:Seek("no_pedido="+norden)
oRs:Fields("Imagen"):Value := 1
ELSE
oRs:Seek("no_pedido="+norden)
oRs:Fields("Imagen"):Value := 0
ENDIF
(aAlias[24])->(Dbskip())
enddo
(aAlias[24])->(Ordscope(0,Nil))
(aAlias[24])->(Ordscope(1,Nil))
endif
(aAlias[24])->(Dbclosearea())
return nil
A ver si algun alma caritativa me da la luz.
Un saludo