FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Twbrowse with ado/sql
Posts: 117
Joined: Thu Jan 08, 2015 09:27 AM
Twbrowse with ado/sql
Posted: Thu Mar 19, 2015 10:08 AM

Hi,

I am doing research to implement ado/sql with my companies Xharbour application, which is now based on dbf technology. I have a class pbrowse which inherit Twbrowse.

My question: Should I still use Twbrowse and modify it, so that it works with ado/sql or should I use another class (for example xbrowse)?

I think one advantage of using Twbrowse is that it is based on the original code of the xharbour application of my company.

I like to know some opinions.

Kind regards,

Pieter

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Twbrowse with ado/sql
Posted: Thu Mar 19, 2015 11:59 AM

Pieter,

As I commented to Erwin, to me the shortest and easiest way is to implement a Method SetAdo() for your Class PBrowse().

You may use Class TXBrowse Method SetAdo() as a reference and Class TWbrowse Method SetArray() as the template to follow.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 117
Joined: Thu Jan 08, 2015 09:27 AM
Re: Twbrowse with ado/sql
Posted: Thu Mar 19, 2015 04:12 PM
Antonio,

Thank you.

I tried to make something, but I am not sure if I understand your advice.

Code (fw): Select all Collapse
CLASS pbrowse From twbrowse

    //All METHODS and VARS of pbrowse

     METHOD SetAdo()

ENDCLASS


METHOD SetAdo( oRs, lAddCols, lAutoOrder, aFldNames ) CLASS pbrowse
//I could make here a TXBrowse object. (I already made something like that before and it worked fine), however I am not sure whether this is the best    //solution, because I did not see a way to make it compatible with the other (dbf based) methods and vars of pbrowse. 
Return Self


I thought I also can do something with ::bline in pbrowse (which come from twbrowse).

While I am writing this post, I suddenly get more ideas again. So later I can further investigate the possible solutions again.

Thanks again:D.

Kind regards,

Pieter
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Twbrowse with ado/sql
Posted: Thu Mar 19, 2015 11:47 PM
Pieter,

Try this:

Code (fw): Select all Collapse
METHOD SetAdo( oRs, cAlias ) CLASS PBrowse

   ::cAlias    = cAlias
   ::bLogicLen = {|| oRs:RecordCount() }
   ::bGoTop    = {|| If( oRs:RecordCount() > 0, oRs:MoveFirst(), nil ) }
   ::bGoBottom := {|| If( oRs:RecordCount() > 0, oRs:MoveLast(), nil )  }
   ::bSkip     := {| n | AdoSkip( oRs, IfNil( n, 1 ) ) }

return nil


Code (fw): Select all Collapse
function AdoSkip( oRs, n )

   LOCAL nRec

   if oRs:RecordCount() == 0
      return 0
   endif

   nRec := oRs:AbsolutePosition
   If( oRs:Eof, oRs:MoveLast(), If( oRs:Bof, oRs:MoveFirst(),) )
   oRs:Move( n )
   If( oRs:Eof, oRs:MoveLast(), If( oRs:Bof, oRs:MoveFirst(),) )

return oRs:AbsolutePosition - nRec
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 117
Joined: Thu Jan 08, 2015 09:27 AM
Re: Twbrowse with ado/sql
Posted: Mon Mar 23, 2015 09:17 AM

Antonio,

Yes, your code works!, I got what I wanted. thank you.

Pieter

Continue the discussion