Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using Like in a SQL Passthru Query
Message
 
 
À
18/04/2011 18:38:36
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01507766
Message ID:
01507767
Vues:
109
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform