Column with progressive number with xBrowse

Column with progressive number with xBrowse

Postby Marco Turco » Wed Jul 09, 2008 6:40 pm

Hi all,
I need to display a column with the progressive number in a xBrowse.

I always used the following command with the standard browse:

ADD COLUMN TO oBrw DATA oBrw:nAt() ;
HEADER "Num" SIZE 30 RIGHT

Do you know the equivalent command to make this with xBrowse ?

Thanks.
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Postby nageswaragunupudi » Wed Jul 09, 2008 10:35 pm

nArrayAt in xBrowse is the same as nAt of WBrowse.
Regards

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

Postby anserkk » Wed Nov 19, 2008 7:52 am

How can I achieve the progressive no's while using Recordset (ADO) with xBrowse

I am getting error when I try nArrayAt and nAt

Error Base/1111 Argument Error : Len From ErroSys, Line:0

Code

Code: Select all  Expand view
*-----------------------------------*
FUNCTION connect()
*-----------------------------------*
Local SQL,oBrw
Local oCon := CreateObject('ADODB.Connection')
Local oRecSet := CreateObject( "ADODB.RecordSet" )

oCon:ConnectionString:= "Driver={MySQL ODBC 3.51 Driver};Server=192.168.0.170;Port=3306;Database=MyDataBase;User=MyUser;Password=MyPassword;Option=3;"
TRY
   oCon:Open()
   msgInfo("Connected to Database") 
CATCH oError
   MsgInfo("Connection Failed")
   RETURN(.F.)
END

oRecSet:CursorLocation := adUseClient
oRecSet:LockType := adLockOptimistic
oRecSet:CursorType := adOpenDynamic
oRecSet:Source := "SELECT * FROM ISSUE_TRA WHERE FIN_YEAR=2004"
oRecSet:ActiveConnection(oCon)
oRecSet:Open()

if oRecSet:BOF .AND. oRecSet:EOF
   Msginfo("No Records")
   Return .F.
Endif

oRecSet:MoveFirst()

@0,0 XBROWSE oBrw ;
     OF oWnd ;         
     OBJECT oRecSet;
     LINES CELL

oCol:=oBrw:AddCol()
oCol:cHeader:="No #"
oCol:bStrdata:={ || oBrw:nArrayAt }   // Problem is here

oBrw:CreateFromCode()

RETURN .T.


Regards

Anser
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Postby Armando » Wed Nov 19, 2008 2:27 pm

Anser:

Try with oRecSet:AbsolutePosition()

Code: Select all  Expand view
oCol:bStrdata:={ || TRANSFORM(oRecSet:AbsolutePosition(),"@Z 99999") }


:AbsolutePosition() it's like RecNo() in DBF's

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

Postby Daniel Garcia-Gil » Wed Nov 19, 2008 3:11 pm

test it...

Code: Select all  Expand view
oCol:bStrData:=GenProgessNumber( oBrw )
....

function GenProgressNumber( oBrw )
return {|| oBrw:nArrayAt }

User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Postby anserkk » Thu Nov 20, 2008 5:04 am

Dear Armando

Your solution worked

Code: Select all  Expand view
oCol:bStrdata:={ || TRANSFORM(oRecSet:AbsolutePosition(),"@Z 99999") }


Dear mcfox

your solution did not work and it was giving error

Code: Select all  Expand view
oCol:bStrData:=GenProgessNumber( oBrw )
....

function GenProgressNumber( oBrw )
return {|| oBrw:nArrayAt }


So I changed your code in function GenProgressNumber( oBrw ) to

Code: Select all  Expand view
function GenProgressNumber( oBrw )
return {|| str(oBrw:nArrayAt) }


By adding str I avoided error but the progressive no in the xBrowse is always 0 in all the lines.

Thanks for your help.

I am writing it down here what I have learned and I hope that it may be useful to newbies like me and help them to reduce their learning curve. Time is valuable

So this is how we get a progressive no in xBrowse

IF Array is used in xBrowse then

Code: Select all  Expand view
oCol:bStrData:={ || oBrw:nArrayAt  }


If DBF is used in xBrowse then

Code: Select all  Expand view
oCol:bStrData:={ || str(  RecNo() )   } // I am doubtful here what happens if the DBF is indexed


If RecordSet is used in xBrowse
Code: Select all  Expand view
oCol:bStrdata:={ || TRANSFORM(oRecSet:AbsolutePosition(),"@Z 99999") }
                OR
oCol:bStrdata:={ || str(oRecSet:AbsolutePosition() ) }


Regards

Anser
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Postby Enrico Maria Giordano » Thu Nov 20, 2008 7:45 am

anserkk wrote:
Code: Select all  Expand view
oCol:bStrData:={ || str(  RecNo() )   } // I am doubtful here what happens if the DBF is indexed


You can use OrdKeyNo() instead. But please build indexes with FOR !Deleted() clause or you will have holes in the numbers sequence.

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

Postby anserkk » Thu Nov 20, 2008 7:50 am

Dear EMG

Is there any other way to show a progressive no on xBrowse when used with a DBF other than using OrdKeyNo() with !Delted clause in the index ?

You can use OrdKeyNo() instead. But please build indexes with FOR !Deleted() clause.


Regards

Anser
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Postby Enrico Maria Giordano » Thu Nov 20, 2008 8:23 am

I don't know, sorry.

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 50 guests