ADO Ms Access Filter Condition

ADO Ms Access Filter Condition

Postby Rick Lipkin » Fri Dec 09, 2011 7:32 pm

To All

I have a Sql statement that runs fine using the Ms Access instr() function and I am trying to modify the script to a filter condition...

This is the Sql statement that runs from the Open() line :

Code: Select all  Expand view

cSQL := "SELECT * FROM REQUEST where instr(PARTDESC,'ba') > 0"

oRsReq := TOleAuto():New( "ADODB.Recordset" )
oRsReq:CursorType     := 1        // opendkeyset
oRsReq:CursorLocation := 3        // local cache
oRsReq:LockType       := 3        // lockoportunistic

TRY
  oRsReq:Open(cSQL,xConnect )
CATCH oErr
  MsgInfo( "Error in Opening REQUEST table" )
  RETURN(.F.)
END TRY
 


Unfortunately, I can not translate it to a filter condition :

oRsReq:Filter := ""
oRsReq:Filter := "instr(PARTDESC,'ba') > 0"

Errors with :

Application
===========
Path and name: C:\Fox\SourceParts\SourceW32.Exe (32 bits)
Size: 2,086,912 bytes
Time from start: 0 hours 0 mins 1 secs
Error occurred at: 12/09/2011, 14:25:44
Error description: Error ADODB.Recordset/6 DISP_E_UNKNOWNNAME: _FILTER
Args:
[ 1] = C instr(PARTDESC,'ba') > 0

Any ideas from anyone on how I can make this filter condition work ?

Thanks
Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: ADO Ms Access Filter Condition

Postby Gale FORd » Fri Dec 09, 2011 7:56 pm

Try this sql string

cSQL := "SELECT * FROM REQUEST where PARTDESC like '%ba%'"
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: ADO Ms Access Filter Condition

Postby Rick Lipkin » Fri Dec 09, 2011 9:15 pm

Gale

Your suggestion was correct .. oRsReq:Filter := "PARTDESC like '%ba%'" .. For some reason I just had a 'brain freeze' and was thinking like the AT() function ..

Thanks
Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 103 guests