May 24, 2005 at 5:39 am
Hello,
Here is a part of the query string:
" where VM_PROPERTY.commercialName like '%"+villaName+"%' "+
The query works fine when I put the villa name directly instead of the dynamic string 'villaName'. When I put the 'villaName' string, it's not taken into consideration.
Can you help me with that please
Thank you beforhand
Zineb
May 24, 2005 at 5:50 am
May 24, 2005 at 6:22 am
What is villaName? Is it a variable, or a constant string that you want to search for? A columnname?
As always, the best way to solve this kind of problem is to simply output the sql string you are trying to execute before sending it to SQL Server. Then you can easily see if the string is correct syntax or not.
May 24, 2005 at 6:48 am
Thank you for your help.
'%'+villaName+'%' didn't work!
villaName is a string where I put the name of the villa 'palais mehdi' for example.
My query is working in query analyser, but when I put '%"+villaName+"%' in my code, it doesn't give me any error and it doesn't take the villa name into consideration. When I put the name of the villa directly in the query, it's working from the code...I'm confused!
Thank you beforehand
Zineb
May 24, 2005 at 4:52 pm
Zineb,
What language are you using to code with? That will help us figure this out with you.
Good Hunting!
AJ Ahrens
webmaster@kritter.net
May 24, 2005 at 4:55 pm
Zineb, please have your code output the sql string that you are executing, right before you execute it. Then post the sql statement here exactly as it is, if you do not immediately spot any error yourself.
May 25, 2005 at 8:10 am
To refer to a variable, use @villaname
May 25, 2005 at 9:02 am
Thank you very much for your trials. I found out that the problem was in a loop I was using in my code. So the synthax '%"+villaName+"%' is right.
Good luck all,
Zineb
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply