Page 1 of 5

Intermittant xBrowse ADO error ( again )

PostPosted: Fri Aug 07, 2009 4:33 pm
by Rick Lipkin
To All

Again I continue to have probles with xBrowse and closure on valid .. here is the error code :

Code: Select all  Expand view

Application
===========
   Path and name: J:\VEHICLE\VEH32.EXE (32 bits)
   Size: 3,496,448 bytes
   Time from start: 4 hours 23 mins 9 secs
   Error occurred at: 08/06/2009, 14:00:54
   Error description: Error ADODB.Recordset/6  DISP_E_UNKNOWNNAME: RECORDCOUNT
   Args:

Stack Calls
===========
   Called from: source\rtl\win32ole.prg => TOLEAUTO:RECORDCOUNT(0)
   Called from: xbrowse.prg => (b)TXBROWSE:SETADO(3765)
   Called from: xbrowse.prg => TXBROWSE:PAINT(1254)
   Called from: xbrowse.prg => TXBROWSE:DISPLAY(957)
   Called from: .\source\classes\CONTROL.PRG => TXBROWSE:HANDLEEVENT(1423)
   Called from: .\source\classes\WINDOW.PRG => _FWH(3333)
   Called from:  => DIALOGBOXINDIRECT(0)
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE(273)
   Called from: .\source\function\ERRSYSW.PRG => ERRORDIALOG(343)
   Called from: .\source\function\ERRSYSW.PRG => (b)ERRORSYS(27)
   Called from: source\rtl\win32ole.prg => TOLEAUTO:RECORDCOUNT(0)
   Called from: xbrowse.prg => (b)TXBROWSE:SETADO(3765)
   Called from: xbrowse.prg => TXBROWSE:PAINT(1254)
   Called from: xbrowse.prg => TXBROWSE:DISPLAY(957)
   Called from: .\source\classes\CONTROL.PRG => TXBROWSE:HANDLEEVENT(1423)
   Called from: .\source\classes\WINDOW.PRG => _FWH(3333)
   Called from:  => DIALOGBOXINDIRECT(0)
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE(273)
   Called from: .\source\function\ERRSYSW.PRG => ERRORDIALOG(343)
   Called from: .\source\function\ERRSYSW.PRG => (b)ERRORSYS(27)
   Called from: source\rtl\win32ole.prg => TOLEAUTO:RECORDCOUNT(0)
   Called from: xbrowse.prg => (b)TXBROWSE:SETADO(3765)
   Called from: xbrowse.prg => TXBROWSE:PAINT(1254)
   Called from: xbrowse.prg => TXBROWSE:DISPLAY(957)
   Called from: .\source\classes\CONTROL.PRG => TXBROWSE:HANDLEEVENT(1423)
   Called from: .\source\classes\WINDOW.PRG => _FWH(3333)
   Called from:  => WINRUN(0)
   Called from: .\source\classes\WINDOW.PRG => TMDIFRAME:ACTIVATE(952)
   Called from: MAIN.PRG => MAIN(381)
 


Here is Line 957

Image

Here is line 1254

Image

Here is line 3765

Image

Here is the valid close for the browse :

Code: Select all  Expand view

IF oRsVEH:eof
   oRsVEH:MoveFirst()
ENDIF

cTITLE := "SELECT * from VEHICLES where AGENCY = '"+xAGENCY+"'"

nWd := GetSysMetrics(0) * .79
nHt := GetSysMetrics(1) * .8

lOK := .F.
DEFINE ICON oICO RESOURCE "KEY"

DEFINE WINDOW oWnd1                        ;
      FROM 10,10 to nHt, nWd PIXEL         ;
      TITLE cTITLE                         ;
      MENU BuildMenu( oRsVeh )             ;
      ICON oICO                            ;
      NOMINIMIZE                           ;
      NOZOOM                               ;
      MDICHILD

@ 0, 0 xBROWSE oBrw of oWnd1               ;
       RECORDSET oRsVeh                    ;
       COLUMNS 'VNUMBER',                  ;
              'TYPE',                      ;
              'LICENSE',                   ;
              'AGENCY',                    ;
              'MEMO',                      ;
              'MAKE',                      ;
              'TYPE',                      ;
              'YEAR',                      ;
              'PROG',                      ;
              'MOTORPOOL',                 ;
              'REGION',                    ;
              'LASTSERVCE',                ;
              'NEXTSERVCE',                ;
              'NEXTMILAGE',                ;
              'SERIALNUMB',                ;
              'ACTIVE',                    ;
              'READONLY'                   ;
       COLSIZES 48,50,80,50,70,120,120,55,95,95,140,80,80,80,190,80,80  ;
       HEADERS "Vnum",                     ;
               "Type",                     ;
               "License",                  ;
               "Agency",                   ;
               "See Memo",                 ;
               "Make",                     ;
               "Model",                    ;
               "Year",                     ;
               "Program",                  ;
               "Mtrpool",                  ;
               "Location",                 ;
               "LastServ",                 ;
               "NextServ",                 ;
               "NextMilage",               ;
               "Serial#",                  ;
               "Act",                      ;
               "ReadOnly"                  ;
       AUTOSORT AUTOCOLS LINES CELL

       oBrw:bClrStd := {|| {CLR_BLACK, if( oRsVeh:Fields("readonly"):Value = 'Y', RGB(179,203,204), CLR_WHITE ) } }

       oBrw:CreateFromCode()
       oWnd1:oClient := oBrw

       oBrw:aCols[2]:bEditValue := { |x|DispType( oRsVeh) }
       oBrw:aCols[5]:bEditValue := { |y|DispMemo( oRsVeh) }

       oBrw:bLDblClick := { |nRow,nCol | _VehView( "V", oRsVeh ) }
       oBrw:bKeyDown   := { |nKey| _Manual( nKey,oRsVeh ) }

ACTIVATE WINDOW oWND1 ;
         ON INIT( oBrw:SetFocus(), .F. ) ;
         VALID ( IIF( !lOK, ( oBrw:lCreated := .f., _VehClose(.T.) ), .F. ))

       *  VALID ( IIF( !lOK, ( oBrw:End(), _VehClose(.T.) ), .F. ))
       *  VALID ( IIF( !lOK, _VehClose(.T.), .F. ))

RETURN( .T. )

//------------------------
static FUNCTION _VehClose( lCLEAN ) //, oRsVEH )

IF lCLEAN = .T.
   lOK := .T.

 *  VEHNUM := oRsVEH:Fields("LICENSE"):Value
 *  FERASE( "C:\DBOVL\VEHNUM.MEM" )
 *  SAVE All like VEHNUM to C:\DBOVL\VEHNUM.MEM

  * oBRW:cALIAS:=NIL
  oBrw:End()

  oRsVEH:CLose()
  oRsVeh := NIL

*  _CleanUP()

ENDIF

RETURN(.T.)


//----------------------------------
// fix for recordcount error

Static function GetKeyCount( oRs )

local nKeyCount := 0

if empty( oRs )
   msginfo( "oRs is nil" )
   RETURN( 0 )
ENDIF


TRY
  nKeyCount := oRs:RecordCount()
CATCH
  nKeyCount := 0
END

return( nKeyCount )
 


As you can see .. there is nothing special here and I have taken everyones advice on closing the browse .. there somewhere from line 957 in the xbrowse code .. the chain of events are still fireing that lead to this intermittant failure.

Any Hints ??

Rick Lipkin

Re: Intermittant xBrowse ADO error ( again )

PostPosted: Fri Aug 07, 2009 5:45 pm
by nageswaragunupudi
Mr Rick

I had earlier suggested a trick, which I don't think you tried till now.
Please try this once.
Instead of
Code: Select all  Expand view
 oBrw:End()
  oRsVEH:CLose()
 

substitute
Code: Select all  Expand view

oBrw:lCreated := .f.
oRsVEH:CLose()
 


What is happening now is, after closing the RecordSet, Browse is being called to Display. Display calls Paint Method "if ::lCreated is .t.". Paint method gives error because by that time recordset is closed.

I am sure Display method does not do anything if oBrw:lCreated is .f. Then paint method won't be called.

If this trick succeeds, we can suggest adding some flag to oBrw:End() method which will inform Display method not to call Paint method.

Re: Intermittant xBrowse ADO error ( again )

PostPosted: Fri Aug 07, 2009 6:15 pm
by Rick Lipkin
Rao

Your suggestion is currently in place :-(

Code: Select all  Expand view


ACTIVATE WINDOW oWND1 ;
         ON INIT( oBrw:SetFocus(), .F. ) ;
         VALID ( IIF( !lOK, ( oBrw:lCreated := .f., _VehClose(.T.) ), .F. ))

       *  VALID ( IIF( !lOK, ( oBrw:End(), _VehClose(.T.) ), .F. ))
       *  VALID ( IIF( !lOK, _VehClose(.T.), .F. ))

//------------------------
static FUNCTION _VehClose( lCLEAN ) //, oRsVEH )

IF lCLEAN = .T.
   lOK := .T.

 *  VEHNUM := oRsVEH:Fields("LICENSE"):Value
 *  FERASE( "C:\DBOVL\VEHNUM.MEM" )
 *  SAVE All like VEHNUM to C:\DBOVL\VEHNUM.MEM

  * oBRW:cALIAS:=NIL
  oBrw:End()

  oRsVEH:CLose()
  oRsVeh := NIL

*  _CleanUP()

ENDIF

RETURN(.T.)

 


Code: Select all  Expand view

Application
===========
   Path and name: J:\VEHICLE\VEH32.EXE (32 bits)
   Size: 3,496,448 bytes
   Time from start: 4 hours 23 mins 9 secs
   Error occurred at: 08/06/2009, 14:00:54
   Error description: Error ADODB.Recordset/6  DISP_E_UNKNOWNNAME: RECORDCOUNT
   Args:

Stack Calls
===========
   Called from: source\rtl\win32ole.prg => TOLEAUTO:RECORDCOUNT(0)
   Called from: xbrowse.prg => (b)TXBROWSE:SETADO(3765)
   Called from: xbrowse.prg => TXBROWSE:PAINT(1254)
   Called from: xbrowse.prg => TXBROWSE:DISPLAY(957)
   Called from: .\source\classes\CONTROL.PRG => TXBROWSE:HANDLEEVENT(1423)
   Called from: .\source\classes\WINDOW.PRG => _FWH(3333)
   Called from:  => DIALOGBOXINDIRECT(0)
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE(273)
   Called from: .\source\function\ERRSYSW.PRG => ERRORDIALOG(343)
   Called from: .\source\function\ERRSYSW.PRG => (b)ERRORSYS(27)
   Called from: source\rtl\win32ole.prg => TOLEAUTO:RECORDCOUNT(0)
   Called from: xbrowse.prg => (b)TXBROWSE:SETADO(3765)
   Called from: xbrowse.prg => TXBROWSE:PAINT(1254)
   Called from: xbrowse.prg => TXBROWSE:DISPLAY(957)
   Called from: .\source\classes\CONTROL.PRG => TXBROWSE:HANDLEEVENT(1423)
   Called from: .\source\classes\WINDOW.PRG => _FWH(3333)
   Called from:  => DIALOGBOXINDIRECT(0)
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE(273)
   Called from: .\source\function\ERRSYSW.PRG => ERRORDIALOG(343)
   Called from: .\source\function\ERRSYSW.PRG => (b)ERRORSYS(27)
   Called from: source\rtl\win32ole.prg => TOLEAUTO:RECORDCOUNT(0)
   Called from: xbrowse.prg => (b)TXBROWSE:SETADO(3765)
   Called from: xbrowse.prg => TXBROWSE:PAINT(1254)
   Called from: xbrowse.prg => TXBROWSE:DISPLAY(957)
   Called from: .\source\classes\CONTROL.PRG => TXBROWSE:HANDLEEVENT(1423)
   Called from: .\source\classes\WINDOW.PRG => _FWH(3333)
   Called from:  => WINRUN(0)
   Called from: .\source\classes\WINDOW.PRG => TMDIFRAME:ACTIVATE(952)
   Called from: MAIN.PRG => MAIN(381)
 



Why is this only happening intermittantly .. I have no problems myself and can not re-create the error .. but yet .. the error.log exists.

Rick Lipkin

Re: Intermittant xBrowse ADO error ( again )

PostPosted: Fri Aug 07, 2009 11:56 pm
by James Bott
Rick,

I am confused by your error listing. I cannot find a call to setAdo() anywhere in the TXBrowse:Paint() method.

What version of FW are you using? Do you see a call to setAdo() in your Paint() method? Are you using a modified version of TXBrowse?

I am using FWH 9.05.

Regards,
James

Re: Intermittant xBrowse ADO error ( again )

PostPosted: Sat Aug 08, 2009 12:37 am
by Rick Lipkin
James

Using FWH 9.06 .. look at xbrowse.prg around line 3758 ..

Rick

Re: Intermittant xBrowse ADO error ( again )

PostPosted: Sat Aug 08, 2009 12:53 am
by James Bott
Rick,

>Using FWH 9.06 .. look at xbrowse.prg around line 3758 ..

I still don't see a call to setAdo().

There are only two calls to setAdo() in my source, one in each of these methods:

Initiate()
XbrwSetDataSource()

That's all.

Is line 3758 in the Paint() method of your version? Can you email me your version of TXBrowse.prg?

jbott at compuserve dot com

James

Re: Intermittant xBrowse ADO error ( again )

PostPosted: Sat Aug 08, 2009 3:26 pm
by Rick Lipkin
James

Just sent you the xbrowse class .. from 9.04 ( not 9.06 .. my mistake ) .. the SetAdo method is around line 3754. Hope your extra set of eyes can shed some light on this problem .. and I think it may be related to the 'print screen' utility these specific users have ..

I have run into something like this before when this 'print screen' utility will force an ON PAINT event when the capture is complete .. forcing Windows to send the event to the OS.

I will wait to see what you think when you receive my e-mail..

Rick Lipkin

Re: Intermittant xBrowse ADO error ( again )

PostPosted: Sat Aug 08, 2009 5:18 pm
by James Bott
Rick,

I have looked at your version of TXBrowse (9.04) and I still don't quite understand the error sequence you are getting. This is your error stack:

Stack Calls
===========
Called from: source\rtl\win32ole.prg => TOLEAUTO:RECORDCOUNT(0)
Called from: xbrowse.prg => (b)TXBROWSE:SETADO(3765)
Called from: xbrowse.prg => TXBROWSE:PAINT(1254)


Paint() line 1254

nBookMark := Eval( ::bBookMark )

SetADO() line 3765

::bKeyCount := {|| GetKeyCount( ::oRs ) }


In SetADO() line 3759, ::bBookmark is difined as:

::bBookMark := {| n | If( n == nil,;
If( ::oRs != nil .and. ::oRs:RecordCount() > 0, ::oRs:BookMark, 0 ), ;
If( ::oRs != nil .and. ::oRs:RecordCount() > 0, ( ::oRs:BookMark := n ), 0 ) ) }, ;

So the Paint() method is eval'ing ::bBookmark, but I don't see how that then gets you to line 3765 in the setAdo() method. Perhaps UltraEdit's line numbers don't match with the error stacks line numbers, and I don't know why the error stack would say that SetADO() was called just because a codeblock was defined there. Strange.

However, it does appear that a call to ::oRs:RecordCount() is what is triggering the error.

As I suggested before I would try a sysrefresh(). I think the event queue is still holding the oBrw:End() when oRsVEH:Close() is being executed. I don't know why this sort of thing happens, but I have had sysrefresh() solve such problems that seemed to defy logic before.

James

Code: Select all  Expand view
static FUNCTION _VehClose( lCLEAN ) //, oRsVEH )

IF lCLEAN = .T.
   lOK := .T.

 *  VEHNUM := oRsVEH:Fields("LICENSE"):Value
 *  FERASE( "C:\DBOVL\VEHNUM.MEM" )
 *  SAVE All like VEHNUM to C:\DBOVL\VEHNUM.MEM

  * oBRW:cALIAS:=NIL
  oBrw:End()

  sysrefresh()  // Add this line - J Bott

  oRsVEH:CLose()
  oRsVeh := NIL

*  _CleanUP()

ENDIF

RETURN(.T.)

Re: Intermittant xBrowse ADO error ( again )

PostPosted: Sat Aug 08, 2009 5:46 pm
by Rick Lipkin
James

I will try your suggestion and let you know ..

Thanks
Rick

Re: Intermittant xBrowse ADO error ( again )

PostPosted: Sat Aug 08, 2009 6:45 pm
by Armando
Rick, James:

When you create an empty Record Set and test using RecordCount() you will have an error.

This code will send you an error with an empty record set

MsgInfo(oRs:RecordCount() > 0)

I use to as follow

IF oRs:BOF() .AND. oRs:EOF()
MsgInfo("The record set is empty !")
ELSE
MsgInfo(oRs:RecordCount())
ENDIF

And I have no problems at all.

I hope this can help you

Regards

Re: Intermittant xBrowse ADO error ( again )

PostPosted: Sat Aug 08, 2009 6:57 pm
by Daniel Garcia-Gil
Hello Rick...

Please try put oBrw:CreateFromCode() last command to create xbrowse
Code: Select all  Expand view

       ....
       ....
       oBrw:bClrStd := {|| {CLR_BLACK, if( oRsVeh:Fields("readonly"):Value = 'Y', RGB(179,203,204), CLR_WHITE ) } }

       oWnd1:oClient := oBrw

       oBrw:aCols[2]:bEditValue := { |x|DispType( oRsVeh) }
       oBrw:aCols[5]:bEditValue := { |y|DispMemo( oRsVeh) }

       oBrw:bLDblClick := { |nRow,nCol | _VehView( "V", oRsVeh ) }
       oBrw:bKeyDown   := { |nKey| _Manual( nKey,oRsVeh ) }

       oBrw:CreateFromCode() // <<======HERE
 

Re: Intermittant xBrowse ADO error ( again )

PostPosted: Sat Aug 08, 2009 7:33 pm
by James Bott
Armando,

So, if I understand correctly, if the record set record count is zero then oRs:RecordCount() will error out? If so, then we can try changing bBookMark to (in the SetADO() method):

::bBookMark := {| n | If( n == nil,;
                     If( ::oRs != nil .and. If( ::oRs:BOF() .AND. oRs:EOF(),0, ::oRs:RecordCount() ) > 0, ::oRs:BookMark, 0 ), ;
                     If( ::oRs != nil .and. If( ::oRs:BOF() .AND. oRs:EOF(),0, ::oRs:RecordCount() ) > 0, ( ::oRs:BookMark := n ), 0 ) ) }, ;

Then this should prevent the errror.

Rick, maybe you should try this first. If we can fix xbrowse to prevent the error it would be the best solution.

James

Re: Intermittant xBrowse ADO error ( again )

PostPosted: Sat Aug 08, 2009 8:32 pm
by Rick Lipkin
Gentleman

All GREAT ideas .. James .. I will modify the xbrowse code for eof, bof ( thanks Armando ) .. this seems to be the root cause !! .. Daniel, I will insert your recommendation as well.

I will vpn into work and make the changes and let everyone know.

Rick

Re: Intermittant xBrowse ADO error ( again )

PostPosted: Sat Aug 08, 2009 8:56 pm
by Rick Lipkin
To All

I have put all the recommendations together ( Daniel, James, and Armando ) .. compiled and tested the applications and it seems to be stable for me ..

I have put the executable in place with the folks that seem to generate the error and will monitor any error.log's ..

Hopefully the eof, bof will be the key ..

Thanks
Rick

Re: Intermittant xBrowse ADO error ( again )

PostPosted: Sun Aug 09, 2009 3:07 am
by Armando
James:

James Bott wrote:So, if I understand correctly, if the record set record count is zero then oRs:RecordCount() will error out?

Yes.

Rick:
I'm glad to hear that.

Regards