Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using Like in a SQL Passthru Query
Message
 
 
To
18/04/2011 18:38:36
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01507766
Message ID:
01507767
Views:
108
This message has been marked as the solution to the initial question of the thread.
>When I run this query from the Query analyzer, I get the all rows within those dates where the sealnumber contains 123
>
>>>SELECT FROM view_depositactivity WHERE postingdate BETWEEN '2011-03-01' AND '2011-03-15' and sealnumber LIKE '%123%'
>
>I'm trying to pass the 123 as a ? argument in a SQL passthru query and can't figure out how to do it.
>
>When I just have the dates in the query I get the right answer.
>
>I'm getting no records back when I use the LIKE clause for the sealnumber
>
>The code below is my latest futile attempt
>
>Any suggestions?
>
>
>lc_sealnumber = "'%" + ALLTRIM(thisform.lc_sealnumber) + "%'"
>    
>lc_sqlstring = "SELECT * FROM view_depositactivity WHERE postingdate BETWEEN ?ld_startdate AND ?ld_enddate "
>lc_sqlstring = lc_sqlstring + " AND sealnumber LIKE ?lc_sealnumber"
>= sqlprepare(gnconnhandle, lc_sqlstring, "curactivity")
>IF oApp.gf_sqlexec(gnconnhandle)
> 
>  SELECT curactivity
>  GO TOP
>  BROWSE
>
>ENDIF 
>
>
>
Try
lc_sealnumber = ALLTRIM(thisform.lc_sealnumber)

lc_sqlstring = "SELECT * FROM view_depositactivity WHERE postingdate BETWEEN ?ld_startdate AND ?ld_enddate "
lc_sqlstring = lc_sqlstring + " AND sealnumber LIKE '%' + ?lc_sealnumber +'%'"
= sqlprepare(gnconnhandle, lc_sqlstring, "curactivity")
IF oApp.gf_sqlexec(gnconnhandle)
 
  SELECT curactivity
  GO TOP
  BROWSE

ENDIF 
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform