Intermittant xBrowse ADO error ( again )

Re: Intermittant xBrowse ADO error ( again )

Postby James Bott » Wed Aug 12, 2009 8:34 pm

Enrico,

I did read your other reply and I do understand about the Windows issue. It doesn't matter if you can end the FW object because the object is still running under windows and thus it can still error out if the database source is ended. This is the point.

I am going to email my test program to you to see if it errors out for you.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Intermittant xBrowse ADO error ( again )

Postby Enrico Maria Giordano » Wed Aug 12, 2009 8:48 pm

James Bott wrote:Enrico,

I did read your other reply and I do understand about the Windows issue. It doesn't matter if you can end the FW object because the object is still running under windows and thus it can still error out if the database source is ended. This is the point.


No. Please look at what End() method does in TWindow (inherited from most of controls):

Code: Select all  Expand view
  METHOD End() BLOCK ;   // It has to be Block
      { | Self, lEnd | If( lEnd := ::lValid(), ::PostMsg( WM_CLOSE ),), lEnd }


It send WM_CLOSE message to the control (Windows API level) effectively destroying it.

James Bott wrote:I am going to email my test program to you to see if it errors out for you.


Ok, but I'd need to compile it to found the real problem.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Intermittant xBrowse ADO error ( again )

Postby Enrico Maria Giordano » Wed Aug 12, 2009 8:50 pm

I received your EXE. It errors out here too but, as I said, I can't see what the real problem is, sorry.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Intermittant xBrowse ADO error ( again )

Postby James Bott » Wed Aug 12, 2009 8:55 pm

Enrico,

>It send WM_CLOSE message to the control (Windows API level) effectively destroying it.

But if you then issue a oBrw:display() there is no error. What does this mean?

>>James Bott wrote:
>>I am going to email my test program to you to see if it errors out for you.
>Ok, but I'd need to compile it to found the real problem.

It is the same source code that I published here (last example), and that you already compiled and tested. I just wanted to see if it was either a FW/Harbour version issue or an OS issue perhaps. You haven't told me which versions you are using.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Intermittant xBrowse ADO error ( again )

Postby Enrico Maria Giordano » Wed Aug 12, 2009 9:06 pm

James Bott wrote:But if you then issue a oBrw:display() there is no error. What does this mean?


You are calling a FWH level method that, in turn, calls some Windows API level functions using an invalid handle. There are no runtime errors for such situations. For example, you can call

ShowWindow( 12345, SW_HIDE )

obtaining no runtime error and no effects.

James Bott wrote:You haven't told me which versions you are using.


Windows XP Pro SP3

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Intermittant xBrowse ADO error ( again )

Postby James Bott » Wed Aug 12, 2009 9:27 pm

Enrico,

>You are calling a FWH level method that, in turn, calls some Windows API level functions using an invalid handle. There are no runtime errors for such situations.

OK, but the FW code in the Display() method is still getting executed, thus the error. So how do we prevent the program from crashing?

On the surface it seems to be a Catch-22, you can't prevent the Display() method from being called until the window is closed and you can't (rather don't want to) close the window until you end the recordset and ending the recordset causes the Display method to be called (under some circumstances).

So, the solution seems to be, as Rao suggested, modifying the XBrowse source to prevent the Paint method from being called when a flag is set. This way we could set the flag, end the recordset, then close the window.

I just noticed that the flag Rao suggested (lCreated) is already in my version of Xbrowse.prg's Display() method. So if you change my test to:

define button of oBar action ( oBrw:lCreated:=.f., oBrw:End(), oBrw:setArray({}), oBrw:display() )

No more error!

Thanks Rao!

Rick, please check if your version of the Display() method looks like this:

Code: Select all  Expand view
METHOD Display() CLASS TXBrowse

   if !::lCreated
      return nil
   endif

   ::BeginPaint()
   ::Paint()
   ::EndPaint()

return 0


If it doesn't, make it so. And then try testing this by setting oBrw:lCreated:=.f. before ending the recordset. Let us know.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Intermittant xBrowse ADO error ( again )

Postby James Bott » Wed Aug 12, 2009 9:54 pm

Rao,

Here is the TXBrowse:Display() method (ver 9.05):

Code: Select all  Expand view
METHOD Display() CLASS TXBrowse

   if !::lCreated
      return nil
   endif

   ::BeginPaint()
   ::Paint()
   ::EndPaint()

return 0


You proposed this modification:

Code: Select all  Expand view
DATA lDataClosed INIT .f.

METHOD End() INLINE ::lDataClosed := Super:End()

METHOD Display()

   if ::lCreated .and. ! ::lDataClosed
       ::BeginPaint()
       ::Paint()
       ::EndPaint()
   endif
return nil

But, couldn't we just use the existing lCreated flag, and just set it to false in the End method? Do we need the new lDataClosed flag, or is this just for clarity? Clarity is good though.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Intermittant xBrowse ADO error ( again )

Postby Enrico Maria Giordano » Wed Aug 12, 2009 11:09 pm

James Bott wrote:OK, but the FW code in the Display() method is still getting executed, thus the error.


The Display() method in your FWH release is causing an error, ok. But the reason of this error is not the browse that has been destroyed. Once more, we need of a clear sample.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Intermittant xBrowse ADO error ( again )

Postby James Bott » Wed Aug 12, 2009 11:19 pm

Enrico,

>The Display() method in your FWH release is causing an error, ok. But the reason of this error is not the browse that has been destroyed.

I'm sorry I don't understand what you are saying. The browse has been "destroyed" but it is still exists and is still functioning. That is why it is erroring out. Maybe this is a matter of symantics. "Destroyed" typically means not in existance anymore. Pehaps in the programming sense it means something else.

Does your version of FWH not error out? If so, what version are you using? What does your Display() method look like?

>Once more, we need of a clear sample.

Again I am confused. I did provide a sample. What do you mean by a "clear sample?" Why is my sample not clear? Did you get the source of the example I emailed you?

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Intermittant xBrowse ADO error ( again )

Postby nageswaragunupudi » Wed Aug 12, 2009 11:20 pm

But, couldn't we just use the existing lCreated flag, and just set it to false in the End method? Do we need the new lDataClosed flag, or is this just for clarity? Clarity is good though.

Yes. We can. Thats what I posted in the beginning.

It is just that the meaning of the statement :lCreated := .f. is not clear to the reader. I proposed the additional flag only for clarity and for no other reason.
I thought after a few months, if one reads the XBrowse code, they would not understand why lCreated is made false.

For example:
Code: Select all  Expand view
METHOD End() INLINE ::lCreated := ! Super:End()

Would achieve the same purpose. But we are sure nobody would understand what this code does.
Last edited by nageswaragunupudi on Thu Aug 13, 2009 12:23 am, edited 3 times in total.
Regards

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

Re: Intermittant xBrowse ADO error ( again )

Postby nageswaragunupudi » Wed Aug 12, 2009 11:37 pm

Mr EMG and Mr James

Instead of using array, please test with this example using DBF
Code: Select all  Expand view

#include 'fivewin.ch'
#include 'xbrowse.ch'
function Main()

   local oWnd, oBar

   USE CUSTOMER

   DEFINE Window oWnd
   define buttonbar oBar of oWnd
   define button of oBar action (oBrw:End(), CUSTOMER->(DbCloseArea()), ;
      oBrw:display(), msgInfo(valtype(oBrw)) )

   @ 0, 0 XBROWSE oBrw OF oWnd ALIAS 'CUSTOMER' AUTOCOLS

   oBrw:CreateFromCode()
   oWnd:oClient:= oBrw
   activate window oWnd

return nil
 

My understanding is this:
Even after executing oBrw:End(), the object still lives. Even if we set oBrw := nil, the other reference in the static array aWindows in window.prg still lives.

We were all suspecting that the line no.3333 in _FWH function of Window.prg is calling this browse object's handle event method after the data source is closed ( in this example, dbf ). This browse object is still in aWindows[nAt]. This handleevent calls Display.
Regards

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

Re: Intermittant xBrowse ADO error ( again )

Postby nageswaragunupudi » Thu Aug 13, 2009 12:39 am

Let us also have another look at the whole issue.
We were all discussing this issue on the assumption that this error is occurring at the time of closing the window, because that is what Mr Rick said. From the error logs there is no evidence that the error is occurring at that time only.

To share my own experiences, we used to face similar errors, though very rarely, even during the browse on some normal operation. Suddenly the recorset stops functioning resulting in painting errors. Nothing wrong with the code or fwh. In a large network environment there could be many external factors that would disturb the connectivity with the servers momentarily or for longer periods effecting the functioning of the recordset.

From then onwards I started disconnecting the recordset after opening and working with the disconnected recordset. ( Reconnect only for requery/refresh/write ). The problems were overcome.

Incidentally I never close the recordset at the end of browse. I use local variable for oRs and let it go out of scope.

( Code for disconnecting recordset is oRs:ActiveConnection:hObj := nil )
Regards

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

Re: Intermittant xBrowse ADO error ( again )

Postby Rick Lipkin » Thu Aug 13, 2009 12:38 pm

Rao, James

I have the same Paint() method and am now using 9.06 .. I have re-compiled the app and seperated the problem lines in setado so if I do get an error .. I can more easily track it to a specific line :

Code: Select all  Expand view

//------------------------------------------------------------------------------//

METHOD SetAdO( oRs, lAddCols, lAutoOrder, aFldNames ) CLASS TXBrowse

   LOCAL nFields,nFor, oCol

   if ::lCreated
      if ::nDataType == DATATYPE_ARRAY
         if SameAdoStruct( Self, oRs )
            return nil
         else
            ::aCols  := {}
         endif
      else
         ::ClearBlocks()
         ::aCols  := {}
      endif
   endif

   msginfo( oRs )   // <--   this fires only on initial browse
                             // if this fires any other time .. I want to see it
   ::oRs    := oRs

   DEFAULT ::bGoTop    := {|| If( ::oRs:RecordCount() > 0, ::oRs:MoveFirst(), nil ) } //,;
   DEFAULT ::bGoBottom := {|| If( ::oRs:RecordCount() > 0, ::oRs:MoveLast(), nil )  } //,;
   DEFAULT ::bSkip     := {| n | AdoSkip( ::oRs, If( n==nil, 1, n ) ) } //,;
   DEFAULT ::bBof      := {|| ::oRs:Bof }  //,;
   DEFAULT ::bEof      := {|| ::oRs:Eof }  //,;
   DEFAULT ::bBookMark := {| n | If( n == nil,;
                                 If( ::oRs:RecordCount() > 0, ::oRs:BookMark, 0 ), ;
                                 If( ::oRs:RecordCount() > 0, ( ::oRs:BookMark := n ), 0 ) ) } // , ;
   DEFAULT ::bKeyNo    := {| n | If( n == nil, ;
                                 If( ::oRs:RecordCount() > 0, ::oRs:AbsolutePosition, 0 ), ;
                                 If( ::oRs:RecordCount() > 0, ( ::oRs:AbsolutePosition := n ), 0 ) ) } //,;
   DEFAULT ::bKeyCount := {|| ::oRs:RecordCount() }
 


I have a meeting with my problem users today @ 2 pm and I want to observe what is goin on here.. I have had this version in place for several days and I have not received a single error.

I will report back what I find later today.

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

Re: Intermittant xBrowse ADO error ( again )

Postby Enrico Maria Giordano » Fri Aug 14, 2009 9:25 am

James Bott wrote:I'm sorry I don't understand what you are saying. The browse has been "destroyed" but it is still exists and is still functioning. That is why it is erroring out.


No. A destroyed control is not functioning and all references to it are invalidated. You can still use them but you just get nothing (no runtime errors and no effects).

James Bott wrote:Does your version of FWH not error out?


Yes, it doesn't error out.

James Bott wrote:If so, what version are you using?


FWH 9.06

James Bott wrote:What does your Display() method look like?


Code: Select all  Expand view
METHOD Display() CLASS TXBrowse

   if !::lCreated
      return nil
   endif

   ::BeginPaint()
   ::Paint()
   ::EndPaint()

return 0


James Bott wrote:Again I am confused. I did provide a sample.


Yes, but your sample (PRG) doesn't error out here so I can't use it to find the reason.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Intermittant xBrowse ADO error ( again )

Postby Enrico Maria Giordano » Fri Aug 14, 2009 10:09 am

nageswaragunupudi wrote:Mr EMG and Mr James

Instead of using array, please test with this example using DBF


Ok, the problem is that in SetRDD() method and maybe in other places of xbrowse.prg the member variable cAlias is used without a test for !Empty(). After these fixes will be made you can use oBrw:cAlias := NIL to solve the problem. This is the same tecnique already used in TWBrowse since years.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], karinha, nageswaragunupudi and 60 guests