FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Intermittant xBrowse ADO error ( again )
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Intermittant xBrowse ADO error ( again )
Posted: Fri Aug 07, 2009 04:33 PM

To All

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

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

Here is line 1254

Here is line 3765

Here is the valid close for the browse :

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

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Intermittant xBrowse ADO error ( again )
Posted: Fri Aug 07, 2009 05:45 PM
Mr Rick

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

substitute
Code (fw): Select all Collapse
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.
Regards



G. N. Rao.

Hyderabad, India
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Intermittant xBrowse ADO error ( again )
Posted: Fri Aug 07, 2009 06:15 PM

Rao

Your suggestion is currently in place :-(

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 (fw): Select all Collapse
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

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Intermittant xBrowse ADO error ( again )
Posted: Fri Aug 07, 2009 11:56 PM

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

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Intermittant xBrowse ADO error ( again )
Posted: Sat Aug 08, 2009 12:37 AM

James

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

Rick

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Intermittant xBrowse ADO error ( again )
Posted: Sat Aug 08, 2009 12:53 AM

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

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Intermittant xBrowse ADO error ( again )
Posted: Sat Aug 08, 2009 03:26 PM

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

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Intermittant xBrowse ADO error ( again )
Posted: Sat Aug 08, 2009 05:18 PM

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

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.)
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Intermittant xBrowse ADO error ( again )
Posted: Sat Aug 08, 2009 05:46 PM

James

I will try your suggestion and let you know ..

Thanks
Rick

Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Re: Intermittant xBrowse ADO error ( again )
Posted: Sat Aug 08, 2009 06:45 PM

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

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
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: Intermittant xBrowse ADO error ( again )
Posted: Sat Aug 08, 2009 06:57 PM

Hello Rick...

Please try put oBrw:CreateFromCode() last command to create xbrowse

       ....
       ....
       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
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Intermittant xBrowse ADO error ( again )
Posted: Sat Aug 08, 2009 07:33 PM

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

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Intermittant xBrowse ADO error ( again )
Posted: Sat Aug 08, 2009 08:32 PM

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

Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Intermittant xBrowse ADO error ( again )
Posted: Sat Aug 08, 2009 08:56 PM

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

Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Re: Intermittant xBrowse ADO error ( again )
Posted: Sun Aug 09, 2009 03:07 AM
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
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