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
XBrowse + ADO
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: XBrowse + ADO
There is nothing wrong with your xbrowse code. XBrowse does not disturb any filters.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: XBrowse + ADO
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:

XBROWSE

LISTBOX:

XBROWSE

Regards,
André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: XBrowse + ADO
Can you do this test please?
Please insert this line
as indicated below:
and post here what is displayed by msginfo() ?
Please insert this line
Code: Select all | Expand
msginfo( oRs:RecordCount )
Code: Select all | Expand
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
G. N. Rao.
Hyderabad, India
Re: XBrowse + ADO
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)

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

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)

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

Regards,
André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
Re: XBrowse + ADO
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.
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
André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
Re: XBrowse + ADO (SOLVED)
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.
I apologize for that and thank you again for your help.
Regards,
André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10