Setting a SQL filter to a number%

Setting a SQL filter to a number%

Postby Rick Lipkin » Thu Sep 15, 2011 9:44 pm

To All

I am trying to set a sql filter to numeric expression against a numeric field and getting a run-time error as a character string ..

Tell me what I am doing wrong :

Code: Select all  Expand view

oRsProp:Filter := ""

if oRsProp:eof
    return(.f.)
endif

oRsProp:MoveFirst()
oRsProp:Filter := "address = '"+alltrim(str(nFIND))+"'"

msginfo( "address like '"+alltrim(str(nFind,0))+"%'"  )

IF oRsProp:eof
    oRsProp:Filter := ""
    oRsProp:Filter := "address like '"+alltrim(str(nFind,0))+"%'" // error here
ENDIF

 



Application
===========
Path and name: C:\Fox\Yacht\YachtW32.Exe (32 bits)
Size: 2,140,160 bytes
Time from start: 0 hours 0 mins 13 secs
Error occurred at: 09/15/2011, 17:40:56
Error description: Error ADODB.Recordset/6 DISP_E_UNKNOWNNAME: _FILTER
Args:
[ 1] = C address like '1%'

Stack Calls
===========
Called from: source\rtl\win32ole.prg => TOLEAUTO:_FILTER(0)
Called from: PropBrow.prg => _LOOKUP(303)
Called from: PropBrow.prg => (b)_PBROW(245)
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:CLICK(445)
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:LBUTTONUP(631)
Called from: => TWINDOW:HANDLEEVENT(0)
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT(1469)
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:HANDLEEVENT(1295)
Called from: .\source\classes\WINDOW.PRG => _FWH(3347)
Called from: => WINRUN(0)
Called from: .\source\classes\WINDOW.PRG => TMDIFRAME:ACTIVATE(966)
Called from: Main.prg => MAIN(264)
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Setting a SQL filter to a number%

Postby Armando » Fri Sep 16, 2011 12:21 am

Rick:

I do this way

Code: Select all  Expand view

oRsMxu:Filter := "usu_num LIKE " + STR(oRsUsu:Fields("USU_NUM"):Value,3,0)
 


usu_num is a Decimal(3,0) and
oRsUsu:Fields("USU_NUM"):Value is a Decimal(3,0) too

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

Re: Setting a SQL filter to a number%

Postby Rick Lipkin » Fri Sep 16, 2011 3:42 pm

Armando

I have an Access Database table Recordset with a numeric field called Address .. I am setting up a search to filter records that start ( like ) with the number 9 which is assigned to the variable nFind ..

nFind := 9
oRsProp:Fields("address"):Value is numeric


Had a difficult time understanding your suggestion :(

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

Re: Setting a SQL filter to a number%

Postby Rick Lipkin » Fri Sep 16, 2011 5:04 pm

To All

I have done some research and found you can in Access create a Sql statement :

SELECT * FROM property WHERE cStr(address) LIKE '9*';

Image

Image

There must be a way to set the same filter condition ..

Rick
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 107 guests