XBrowse + ADO

XBrowse + ADO

Postby ADutheil » Wed Feb 16, 2011 4:44 pm

I´m changing the browse of all my apps to use xbrowse. One of them use ADO to connect to a MS-SQL database. The folowing code works OK:
LOCAL oRs := HB_AdoRddGetRecordSet()

IF PegaData( @dData )
IF !empty( dData )
oRs:Filter := "data_release = '" + dToC( dData ) + "'"
ELSE
oRs:Filter := NIL
ENDIF
IF oRs:RecordCount > 0

DEFINE DIALOG oDlgs RESOURCE "SELECAO" OF wndMain()
REDEFINE LISTBOX oLbx FIELDS oRs:Fields( 1 ):Value, subStr( oRs:Fields( 2 ):Value, 1, 75 ) HEADERS "DATA", "TÍTULO" ;
SIZES 80,200 ID 103 OF oDlgs ON DBLCLICK( DigitaAlte( oRs ), oLbx:refresh() ) UPDATE
oLbx:bLogicLen := { || oRs:RecordCount }
oLbx:bGoTop := { || oRs:MoveFirst() }
oLbx:bGoBottom := { || oRs:MoveLast() }
oLbx:bSkip := { | nSkip | Skipper( oRs, nSkip ) }
oLbx:cAlias := "ARRAY"
oDlgs:lHelpIcon := .f.
ACTIVATE DIALOG oDlgs
.............................................
When I change to xbrowse the filter is ignored and all the dates are displayed.

LOCAL oRs := HB_AdoRddGetRecordSet()

IF PegaData( @dData )
IF !empty( dData )
oRs:Filter := "data_release = '" + dToC( dData ) + "'"
ELSE
oRs:Filter := NIL
ENDIF
IF oRs:RecordCount > 0

DEFINE WINDOW oDlgs MDICHILD OF wndMain() TITLE "Alteração de notícia"
oLbx := TXBrowse():New( oDlgs )
oLbx:SetAdO( oRs, .t., .t., { "data_release", "titulo" } )
oLbx:aCols[ 1 ]:cHeader := "DATA"
oLbx:aCols[ 2 ]:cHeader := "TÍTULO"
oLbx:aCols[ 2 ]:nWidth := 530
oLbx:bLDblClick := { || DigitaAlte( oRs ), oLbx:refresh() }
oLbx:CreateFromCode()
oDlgs:oClient := oLbx
ACTIVATE WINDOW oDlgs ON INIT oDlgs:aControls[ 1 ]:SetFocus()

What am I doing wrong?


TIA
Regards,

André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
ADutheil
 
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: XBrowse + ADO

Postby nageswaragunupudi » Thu Feb 17, 2011 6:06 am

There is nothing wrong with your xbrowse code. XBrowse does not disturb any filters.
Regards

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

Re: XBrowse + ADO

Postby ADutheil » Thu Feb 17, 2011 11:32 am

If there is nothing wrong with my code and nothing wrong with xbrowse how do you explain the different result for the same selected date?

LISTBOX:
Image

XBROWSE
Image
Regards,

André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
ADutheil
 
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: XBrowse + ADO

Postby nageswaragunupudi » Thu Feb 17, 2011 12:27 pm

Can you do this test please?
Please insert this line
Code: Select all  Expand view
msginfo( oRs:RecordCount )
as indicated below:
Code: Select all  Expand view
IF oRs:RecordCount > 0

   msginfo( oRs:RecordCount )  // insert here
   
   DEFINE WINDOW oDlgs MDICHILD OF wndMain() TITLE "Alteração de notícia"
   oLbx := TXBrowse():New( oDlgs )
 

and post here what is displayed by msginfo() ?
Regards

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

Re: XBrowse + ADO

Postby ADutheil » Thu Feb 17, 2011 12:34 pm

In both cases return 3.
Regards,

André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
ADutheil
 
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: XBrowse + ADO

Postby ADutheil » Thu Feb 17, 2011 4:37 pm

I modified souce this way:
DEFINE WINDOW oDlgs MDICHILD OF wndMain() TITLE "Alteração de notícia"
oLbx := TXBrowse():New( oDlgs )
oLbx:SetAdO( oRs, .t., .t., { "data_release", "titulo" } )
oLbx:aCols[ 1 ]:cHeader := "DATA"
oLbx:aCols[ 2 ]:cHeader := "TÍTULO"
oLbx:aCols[ 2 ]:nWidth := 530
//oLbx:bLDblClick := { || DigitaAlte( oRs ), oLbx:refresh() }
oLbx:bLDblClick := { || msginfo( oRs:RecordCount ) }

oLbx:CreateFromCode()
oDlgs:oClient := oLbx
ACTIVATE WINDOW oDlgs ON INIT ( oDlgs:aControls[ 1 ]:SetFocus(), msginfo( oRs:RecordCount ) )

On first image you can see the browse is created with the correct 3 records (date selected 15/02/11)
Image

But when the browse expands to window full size it displays all the rows and dblclick returns 695
Image
Regards,

André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
ADutheil
 
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: XBrowse + ADO

Postby ADutheil » Fri Feb 18, 2011 7:07 pm

It seems that the ADO_CLEARFILTER() function is called from somewhere because when I modify it from

STATIC FUNCTION ADO_CLEARFILTER( nWA )

LOCAL oRecordSet := USRRDD_AREADATA( nWA )[ WA_RECORDSET ]

BEGIN SEQUENCE WITH {| oErr | Break( oErr ) }
//oRecordSet:Filter := ""
RECOVER
END SEQUENCE

RETURN HB_SUCCESS

to

STATIC FUNCTION ADO_CLEARFILTER( nWA )

LOCAL oRecordSet := USRRDD_AREADATA( nWA )[ WA_RECORDSET ]

BEGIN SEQUENCE WITH {| oErr | Break( oErr ) }
//oRecordSet:Filter := ""
RECOVER
END SEQUENCE

RETURN HB_SUCCESS


the browse is shown correctly.
Regards,

André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
ADutheil
 
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: XBrowse + ADO (SOLVED)

Postby ADutheil » Sun Feb 20, 2011 2:33 pm

The is no problem with XBrowse + ADO. The error was due to my mistake: at the same time I changed listbox to xbrowse, I changed a nodal dialog to non modal child window and there was a clear filter command before the return of the function.
I apologize for that and thank you again for your help.
Regards,

André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
ADutheil
 
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 80 guests