Error con ADO y XBrowse en recurso (Solucionado)

Error con ADO y XBrowse en recurso (Solucionado)

Postby cmsoft » Wed May 22, 2013 3:08 pm

Estimados:
Estoy queriendo mostrar una consulta en un Xbrowse que defino en un recurso, pero me da un error. La misma consulta si la muestro con la función xbrowse funciona correctamente.
Seguramente algo básico estoy haciendo mal porque estoy comenzando con esto, por eso recurro a la buena predisposición del foro.
Code: Select all  Expand view  RUN

oRs := TOleAuto():New("ADODB.Recordset")
oRs:Open(cSql,oCn)
DEFINE WINDOW oWnd1 MDICHILD TITLE "RESULTADO DE LA CONSULTA" OF oWnd NOZOOM ICON oIco
         DEFINE BUTTONBAR oBar  SIZE 60,60 OF oWnd1 2010
         DEFINE BUTTON RESOURCE "EXCE" OF oBar   TOOLTIP "Exportar a Excel"  ;
                    ACTION oBrw:ToExcel()  PROMPT "Exporta" TOP
         DEFINE BUTTON RESOURCE "IMPR" OF oBar TOOLTIP "Imprimir Planilla"  ;
                    ACTION oBrw:Report("Reporte",.T.,.F.) PROMPT "Reporte" TOP
         DEFINE BUTTON RESOURCE "SALE" OF oBar TOOLTIP "Cerrar Ventana" ;
                    ACTION oWnd1:End()  PROMPT "Cerrar" TOP
   oWnd1:bGotFocus := { || oDlg:SetFocus}
   oWnd1:bResized := { || Incrusta( oWnd1, oDlg, .t.) }
     DEFINE DIALOG oDlg RESOURCE "ABMS" OF oWnd1
     oBrw := TXBrowse():New()
    REDEFINE XBROWSE oBrw ID 111 OF oDlg RECORDSET oRs  AUTOCOLS AUTOSORT CELL
     // Activo el dialogo y al iniciar muevo a 0,0
     ACTIVATE DIALOG oDlg NOWAIT ON INIT oDlg:Move(0,0)
   ACTIVATE WINDOW oWnd1 ON INIT Incrusta( oWnd1, oDlg, .T.)
 

El error que me genera al mostrar el dialogo es el siguiente
Code: Select all  Expand view  RUN
Application
===========
   Path and name: F:\ado.exe (32 bits)
   Size: 2,131,456 bytes
   Compiler version: Harbour 3.1.0dev (Rev. 17114)
   FiveWin  Version: FWH 11.11
   Windows version: 5.1, Build 2600 Service Pack 3

   Time from start: 0 hours 0 mins 51 secs
   Error occurred at: 22/05/2013, 11:55:42
   Error description: (DOS Error -2147352567) WINOLE/1007  Argument error: RECORDCOUNT

Stack Calls
===========
   Called from:  => TOLEAUTO:RECORDCOUNT( 0 )
   Called from: .\source\classes\XBROWSE.PRG => (b)TXBROWSE_SETADO( 4277 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:PAINT( 1381 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:DISPLAY( 1250 )
   Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1665 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:HANDLEEVENT( 11627 )
   Called from: .\source\classes\WINDOW.PRG => _FWH( 3169 )
   Called from:  => SYSREFRESH( 0 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:END( 508 )
   Called from: .\source\function\ERRSYSW.PRG => (b)ERRORDIALOG( 407 )
   Called from: .\source\classes\BUTTON.PRG => TBUTTON:CLICK( 157 )
   Called from: .\source\classes\CONTROL.PRG => TBUTTON:HANDLEEVENT( 1653 )
   Called from: .\source\classes\WINDOW.PRG => _FWH( 3169 )
   Called from:  => SENDMESSAGE( 0 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:COMMAND( 379 )
   Called from:  => TWINDOW:HANDLEEVENT( 0 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:HANDLEEVENT( 882 )
   Called from:  => DIALOGBOXINDIRECT( 0 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 270 )
   Called from: .\source\function\ERRSYSW.PRG => ERRORDIALOG( 426 )
   Called from: .\source\function\ERRSYSW.PRG => (b)ERRORSYS( 31 )
   Called from:  => TOLEAUTO:RECORDCOUNT( 0 )
   Called from: .\source\classes\XBROWSE.PRG => (b)TXBROWSE_SETADO( 4277 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:PAINT( 1381 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:DISPLAY( 1250 )
   Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1665 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:HANDLEEVENT( 11627 )
   Called from: .\source\classes\WINDOW.PRG => _FWH( 3169 )
   Called from:  => DIALOGBOXINDIRECT( 0 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 270 )
   Called from: .\source\function\ERRSYSW.PRG => ERRORDIALOG( 426 )
   Called from: .\source\function\ERRSYSW.PRG => (b)ERRORSYS( 31 )
   Called from:  => TOLEAUTO:RECORDCOUNT( 0 )
   Called from: .\source\classes\XBROWSE.PRG => (b)TXBROWSE_SETADO( 4277 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:PAINT( 1381 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:DISPLAY( 1250 )
   Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1665 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:HANDLEEVENT( 11627 )
   Called from: .\source\classes\WINDOW.PRG => _FWH( 3169 )
   Called from:  => WINRUN( 0 )
   Called from: .\source\classes\WINDOW.PRG => TMDIFRAME:ACTIVATE( 990 )
   Called from: ADO.prg => MAIN( 51 )


Gracias de antemano por su colaboración
Last edited by cmsoft on Thu May 23, 2013 1:15 pm, edited 1 time in total.
User avatar
cmsoft
 
Posts: 1291
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: Error con ADO y XBrowse en recurso

Postby FranciscoA » Wed May 22, 2013 6:38 pm

Hola cmsoft, intenta omitiendo esta linea: //oBrw := TXBrowse():New()
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2159
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: Error con ADO y XBrowse en recurso

Postby cmsoft » Wed May 22, 2013 7:59 pm

Gracias por responder Francisco.
Esa linea la tengo comentada, copie mal acá, pero igual da el mismo error.
User avatar
cmsoft
 
Posts: 1291
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: Error con ADO y XBrowse en recurso

Postby cmsoft » Thu May 23, 2013 1:15 pm

La solucion estaba en el foro!!!

Code: Select all  Expand view  RUN
 // Defino el dialogo tomado del recurso ABMCAJA
   DEFINE WINDOW oWnd1 MDICHILD TITLE "RESULTADO DE LA CONSULTA" ;
          OF oWnd NOZOOM ICON oIco
         DEFINE BUTTONBAR oBar  SIZE 60,60 OF oWnd1 2010
         DEFINE BUTTON RESOURCE "EXCE" OF oBar ;
            TOOLTIP "Exportar a Excel" ;
            ACTION oBrw:ToExcel() ;
            PROMPT "Exporta" TOP
         DEFINE BUTTON RESOURCE "IMPR" OF oBar ;
            TOOLTIP "Imprimir Planilla"  ;
            ACTION oBrw:Report("Reporte",.T.,.F.);
            PROMPT "Reporte" TOP
         // Este boton cierra la aplicacion
         DEFINE BUTTON RESOURCE "SALE" OF oBar;
            TOOLTIP "Cerrar Ventana" ;
            ACTION oWnd1:End();
            PROMPT "Cerrar" TOP
   DEFINE DIALOG oDlg RESOURCE "ABMS" OF oWnd1              
   oWnd1:bGotFocus := { || oDlg:SetFocus}
   oWnd1:bResized := { || Incrusta( oWnd1, oDlg, .t.) }
   oBrw := TXBrowse():New( oDlg )
   oBrw:SetAdo(oRs,.T.,.T.)
   oBrw:nMarqueeStyle       := MARQSTYLE_HIGHLCELL
   oBrw:nColDividerStyle    := LINESTYLE_BLACK
   oBrw:nRowDividerStyle    := LINESTYLE_BLACK
   oBrw:lColDividerComplete := .t.
   oBrw:CreateFromResource(111)
  // Activo el dialogo y al iniciar muevo a 0,0
   ACTIVATE DIALOG oDlg NOWAIT ON INIT oDlg:Move(0,0)  CENTER
ACTIVATE WINDOW oWnd1 ON INIT Incrusta( oWnd1, oDlg, .T.) Valid( oRs:Close() = nil)
Last edited by cmsoft on Thu May 23, 2013 4:29 pm, edited 1 time in total.
User avatar
cmsoft
 
Posts: 1291
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: Error con ADO y XBrowse en recurso (Solucionado)

Postby Antonio Linares » Thu May 23, 2013 1:57 pm

Parece un error de la gestión de objetos OLE de Harbour, de lo que sería aconsejable que pruebes con la versión más reciente de Harbour y FWH

Fíjate que el sistema de errores de OLE dice que se le ha suministrado un parámetro erróneo a RecordCount pero desde el código no se le ha pasado ningún parámetro. De ahi. el suponer que el fallo viene de la versión de Harbour usada.

Supongo que estas usando la clase xbrowse original de FWH y que no la has modificado, por lo que recordcount() no recibe parámetros. Revisa xbrowse.prg y busca por recordcount

Error description: (DOS Error -2147352567) WINOLE/1007 Argument error: RECORDCOUNT // aqui indica de un error de parámetro

Stack Calls
===========
Called from: => TOLEAUTO:RECORDCOUNT( 0 ) // el cero significa que no se han usado parámetros
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42118
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Error con ADO y XBrowse en recurso (Solucionado)

Postby nageswaragunupudi » Fri May 24, 2013 5:19 am

Another suggestion:

The errir
Code: Select all  Expand view  RUN
Called from:  => TOLEAUTO:RECORDCOUNT( 0 )

arises when oRs is closed when the browse is trying to paint.

In case of MDICHILD windows, it is advised to close oRs in oWnd:bPostEnd codeblock, but not in VALID clause.

oWnd:bPostEnd := { || oRs:Close() }.
This is the safest way to avoid such errors.
Also we need to make sure that we are not closing the oRs elsewhere in the program by mistake.
Regards

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

Re: Error con ADO y XBrowse en recurso (Solucionado)

Postby Rick Lipkin » Fri May 24, 2013 1:12 pm

Rao is correct .. this particular error drives me nuts from time to time ..

Stack Calls
===========
Called from: => TOLEAUTO:RECORDCOUNT( 0 )
Called from: .\source\classes\XBROWSE.PRG => (b)TXBROWSE_SETADO( 4277 )
Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:PAINT( 1381 )
Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:DISPLAY( 1250 )
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1665 )
Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:HANDLEEVENT( 11627 )
Called from: .\source\classes\WINDOW.PRG => _FWH( 3169 )
Called from: => SYSREFRESH( 0 )



Here is a sample of my Mdi\Child valid close .. note the code blocks

oLbxA:bKeyCount := { || 0 }
oLbxA:bKeyNo := { || 0 }

Code: Select all  Expand view  RUN

//---------------------------------------------
Static FUNCTION ExitPgm( lOk3,oWndChildA,oWndCHild,oLbxA,lOk,;
                         oLbx,oFontB,oFontB1,oRsSch,oWndChildB,lOpen,oRsRepair  )

LOCAL lOK1

*Msginfo( "ExitPgm  closing schedule")
*msginfo( "Value of oWndChildB")
*msginfo( oWndChildB )


IF lOk3 = .T.
   lOK  := .T.
   lOK1 := lOK

   Try
      oWndChildB:end()
   Catch
   End Try

   oRsSch:CLose()
   oRsSch := NIL

   If lOpen = .t.             // t = had to open from main
      oRsRepair:CLose()   // f = came from workbrow
      oRsRepair := nil
   Endif

   oLbxA:bKeyCount := { || 0 }  
   oLbxA:bKeyNo    := { || 0 }

   oFontB:End()
   oFontB1:End()

   If lOpen = .f.
      oWndChild:Show()

      oLbx:ReFresh()
      oLbx:SetFocus()
   ENdif

ENDIF

RETURN( lOK1 )
 


Second suggestion is to NOT use SysReFresh() anywhere in your xBrowse code .. even a debugging MsgINfo() contains an embeded SysRefresh() that will cause your run-time error.

Stack Calls
===========
Called from: => TOLEAUTO:RECORDCOUNT( 0 )
Called from: .\source\classes\XBROWSE.PRG => (b)TXBROWSE_SETADO( 4277 )
Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:PAINT( 1381 )
Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:DISPLAY( 1250 )
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1665 )
Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:HANDLEEVENT( 11627 )
Called from: .\source\classes\WINDOW.PRG => _FWH( 3169 )
Called from: => SYSREFRESH( 0 )



Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2666
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Error con ADO y XBrowse en recurso (Solucionado)

Postby nageswaragunupudi » Fri May 24, 2013 3:00 pm

Mr Rick

As I suggested, please close oRs only in oWnd:bPostEnd codeblock and then forget all about the problem.

Clarification:
bValid is executed prior to closing the window. At that time Browse and all other controls are still alive. It is possible that any of them need to be repainted. Then this error occurs.

bPostEnd is executed after the window is closed and all controls are destroyed. If the oRs is closed at that time, there is no control requiring access to the oRs.

Same is the case with closing DBFs also.
Regards

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

Re: Error con ADO y XBrowse en recurso (Solucionado)

Postby Armando » Fri May 24, 2013 5:03 pm

Friends:

I do that in this way and not problem at all:

Code: Select all  Expand view  RUN

ACTIVATE WINDOW oWnd ON INIT ....   VALID CloseRS()
RETURN (NIL)

/*
* --------------------------------------------------------------------------*
* --------------------------------------------------------------------------*
*/

STATIC FUNCTION CloseRS()
    oWnd        := NIL
    IF oRsMyRs <> NIL
        IF oRsMyRs:State() = adStateOpen
            oRsMyRs:Close()
        ENDIF
    ENDIF
RETURN(.T.)
 


Regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3229
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Error con ADO y XBrowse en recurso (Solucionado)

Postby Rick Lipkin » Fri May 24, 2013 5:24 pm

Rao

I like your solution .. and I totally agree with you.. but where would you place the
Code: Select all  Expand view  RUN

oWnd:bPostEnd := { || oRs:Close() }.
 


right after the oWnd:CLose() ?
Code: Select all  Expand view  RUN

oWnd:CLose()
oWnd:bPostEnd := { || oRs:Close() }.
 


Thanks
Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2666
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Error con ADO y XBrowse en recurso (Solucionado)

Postby cmsoft » Fri May 24, 2013 8:28 pm

Gracias a todos por las respuestas y sugerencias!
Me quedo con la solución de poner oWnd:bPostEnd := { || oRs:Close() }
Muchas gracias!
User avatar
cmsoft
 
Posts: 1291
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: Error con ADO y XBrowse en recurso (Solucionado)

Postby nageswaragunupudi » Fri May 24, 2013 10:43 pm

I like your solution .. and I totally agree with you.. but where would you place the

Anywhere before ACTIVATE WINDOW oWnd
Regards

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

Re: Error con ADO y XBrowse en recurso (Solucionado)

Postby nageswaragunupudi » Fri May 24, 2013 10:46 pm

Mr Armando

Closing recset or dbf in VALID clause normally works. But it is not in our control when a control of the window tries to access recset/dbf after execution of valid statement and before destruction of the control.

So, it is safe to close recset / dbf in the oWnd:bPostEnd codeblock.
Regards

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

Re: Error con ADO y XBrowse en recurso (Solucionado)

Postby Armando » Sat May 25, 2013 5:42 pm

Mr. Rao:

I understood, thanks.

Regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3229
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: SantaCroya and 53 guests