Sample ADO and Xbrowse

Sample ADO and Xbrowse

Postby Armando » Wed Sep 19, 2007 11:11 pm

Dear friends:

I'm looking for a small sample using ADO (RECORDSET) and TXBrowse, if you have one this will be very very appreciated.

Best 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: 3228
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Postby nageswaragunupudi » Sun Sep 23, 2007 11:44 am

Please try to adopt this code:
Code: Select all  Expand view  RUN
FUNCTION rsxbrowse( rs )

LOCAL   oWnd, oBrw, oCol


   DEFINE WINDOW oWnd

   oBrw                 := TXBrowse():New(oWnd)

   oBrw:bGoTop          := {|| rs:moveFirst() }
   oBrw:bGoBottom       := {|| rs:moveLast() }
   oBrw:bSkip           := {| n | rsSkipper( n, rs ) }
   oBrw:bBof            := {|| rs:Bof() }
   oBrw:bEof            := {|| rs:Eof() }
   oBrw:bBookMark       := {| bmNew | IIF( bmNew == NIL, rs:bookMark, rs:bookMark := bmNew) }
   oBrw:bKeyNo          := {|| rs:AbsolutePosition }
   oBrw:bKeyCount       := {|| rs:RecordCount() }

   oCol                 := oBrw:AddCol()
   WITH OBJECT oCol
      :bStrData         := {|| cValToChar( rs:fields(0):Value ) }
      :cHeader          := rs:fields(0):Name
   END

   oCol                 := oBrw:AddCol()
   WITH OBJECT oCol
      :bStrData         := {|| cValToChar( rs:fields(1):Value ) }
      :cHeader          := rs:fields(1):Name
   END

   // and so on for other columns

   oBrw:CreateFromCode()
   oWnd:oClient         := oBrw

   ACTIVATE WINDOW oWnd

   RETURN NIL
//------------------------------------------------------------------------------
STATIC FUNCTION RsSkipper( nToSkip, rs )

   LOCAL nSkipped    := 0
   LOCAL nCurPos

   IF nToSkip == NIL
      nToSkip     := 1
   ENDIF

   IF rs:RecordCount() > 0

      nCurPos              := rs:AbsolutePosition
      rs:AbsolutePosition  := MAX( 1, MIN( nCurPos + nToSkip, rs:RecordCount() ) )
      nSkipped             := rs:AbsolutePosition - nCurPos

   ENDIF

   RETURN nSkipped
//------------------------------------------------------------------------------


NageswaraRao
Regards

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

Postby Armando » Sun Sep 23, 2007 1:04 pm

NageswaraRao:

Thanks a lot, your code is very clear.

Thanks again

Kind 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: 3228
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: nageswaragunupudi and 88 guests