FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour ADO: filter does not work on memo fields [fixed]
Posts: 838
Joined: Wed Aug 22, 2007 10:09 AM
ADO: filter does not work on memo fields [fixed]
Posted: Mon Jan 27, 2020 10:02 AM

Hi,

Performing a filter on ADO (oRs:Filter) using LIKE on a memo field does not work.

Is there a way?

Thank you.

Saludos / Regards,



FWH 20.04, Harbour 3.2.0 dev (r1909261630) y BCC 7.40
Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Re: ADO: filter does not work on memo fields
Posted: Mon Jan 27, 2020 05:14 PM

Moises:

It Works fine to me.

Show us your code, pls.

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
Posts: 838
Joined: Wed Aug 22, 2007 10:09 AM
Re: ADO: filter does not work on memo fields
Posted: Mon Jan 27, 2020 06:54 PM
Armando,

This is the code:

Code (fw): Select all Collapse
cFiltro := cCampo + space(1) + "LIKE" + space(1) + "'%"+alltrim(cLiteral)+"%'"


It works except on memo fields.

Thank you.
Saludos / Regards,



FWH 20.04, Harbour 3.2.0 dev (r1909261630) y BCC 7.40
Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Re: ADO: filter does not work on memo fields
Posted: Mon Jan 27, 2020 09:13 PM
Moises:

This is may code, the CLI_NOM field is a TEXT type field.

Code (fw): Select all Collapse
STATIC FUNCTION FilNom(oDlg,oBrw,aGets)
    cFilNom := ALLTRIM(cFilNom)

    IF ! EMPTY(cFilNom)
        IF oRsPry:BOF() .AND. oRsPry:EOF()
            MsgInfo("No hay obras donde buscar !",oApp:cAplicacion)
        ELSE
            oRsPry:Filter := "CLI_NOM LIKE " + "'%" + cFilNom + "%'"
            IF oRsPry:BOF() .AND. oRsPry:EOF()
                MsgInfo("Cliente " + cFilNom + " no localizado !",oApp:cAplicacion)
                oRsPry:Filter := adFilterNone
            ENDIF
        ENDIF
    ELSE
        oRsPry:Filter := adFilterNone
    ENDIF

    oBrw:Refresh()
    oDlg:Update()
    cFilNom := SPACE(40)
    aGets[02]:oJump := oBrw
RETURN(.T.)


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
Posts: 838
Joined: Wed Aug 22, 2007 10:09 AM
Re: ADO: filter does not work on memo fields
Posted: Tue Jan 28, 2020 07:52 AM

Yes, in text fields works, but not in memo fields, where I have the issue.

Thank you.

Saludos / Regards,



FWH 20.04, Harbour 3.2.0 dev (r1909261630) y BCC 7.40
Posts: 838
Joined: Wed Aug 22, 2007 10:09 AM
Re: ADO: filter does not work on memo fields
Posted: Mon Feb 10, 2020 08:28 AM

Up!

Saludos / Regards,



FWH 20.04, Harbour 3.2.0 dev (r1909261630) y BCC 7.40
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: ADO: filter does not work on memo fields
Posted: Thu Feb 13, 2020 01:47 PM

There is not Memo Field type in any sql database, MSAccess, MySql or MSSql
In MSAccess, MySql, MSSql the field type is TEXT.
In Oracle the field type is also called CLOB

Regards



G. N. Rao.

Hyderabad, India
Posts: 838
Joined: Wed Aug 22, 2007 10:09 AM
Re: ADO: filter does not work on memo fields
Posted: Thu Feb 13, 2020 03:02 PM
Yes, I mean long text or blob fields.

In such fields, this line does not work:

Code (fw): Select all Collapse
cFilter := cFieldName + space(1) + "LIKE" + space(1) + "'%"+alltrim(cUserText)+"%'"
Saludos / Regards,



FWH 20.04, Harbour 3.2.0 dev (r1909261630) y BCC 7.40
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: ADO: filter does not work on memo fields
Posted: Sat Feb 15, 2020 03:47 AM
In our tests, filters on LONGTEXT fields are working.

This is the test program:
Code (fw): Select all Collapse
#include "fivewin.ch"

function Main()

   local oCn, cSql, oRs

   oCn   := FW_DemoDB( "ADO" )

   TRY
      oCn:Execute( "DROP TABLE testmemo" )
   CATCH
   END

TEXT INTO cSql
CREATE TABLE testmemo (
  id INT AUTO_INCREMENT PRIMARY KEY
 ,name VARCHAR(10)
 ,memo LONGTEXT
)
ENDTEXT

   oCn:Execute( cSql )

TEXT INTO cSql
INSERT INTO testmemo ( name, memo ) VALUES
  ( "AAA", "one two three" ),
  ( "BBB", "three four five" ),
  ( "CCC", "five six seven" )
ENDTEXT

   oCn:Execute( cSql )

   oRs   := FW_OpenRecordSet( oCn, "testmemo" )
   ? oRs:RecordCount()  // ----------------------> 3
   oRs:Filter := "MEMO LIKE %three%"
   oRs:MoveFirst()
   ? oRs:RecordCount()  // ----------------------> 2 : Filter success

   oRs:Close()
   oCn:Close()

return nil
Regards



G. N. Rao.

Hyderabad, India
Posts: 838
Joined: Wed Aug 22, 2007 10:09 AM
Re: ADO: filter does not work on memo fields
Posted: Sat Feb 15, 2020 04:32 PM

My mistake: I was using oBrw:oRs instead of oRs with all fields.

Thank you.

Saludos / Regards,



FWH 20.04, Harbour 3.2.0 dev (r1909261630) y BCC 7.40

Continue the discussion