Click here to Skip to main content
15,905,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have this code:

CommandText = "SELECT * FROM ContactsData WHERE VandutLaData BETWEEN LIKE %" + Converter.Encrypt(lblDataDeLa.Text) + "% AND LIKE %" + Converter.Encrypt(lblPanaLaData.Text) + "%";


but i get the error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIKE  %FBKEHKEIKFFKEHKFAKEIKEJKEI% AND LIKE %FBKEHKEIKFFKEHKFAKEIKEJKEI%' at line 1


What am I mising?
Posted
Updated 4-Jul-10 11:56am
v6
Comments
Ankur\m/ 5-Jul-10 0:40am    
I guess the answer by Martin solved your issue. Please select "Accept Answer" which would mark the question as 'solved'.

Single quotes around the LIKE paramater?

LIKE '%FBKEHKEIKFFKEHKFAKEIKEJKEI%'
 
Share this answer
 
I change my code to:

CommandText = "SELECT * FROM ContactsData WHERE VandutLaData BETWEEN LIKE \'%" + Converter.Encrypt(lblDataDeLa.Text) + "%\' AND LIKE \'%" + Converter.Encrypt(lblPanaLaData.Text)+ "%\'";


but now a get the eror:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIKE '%%' AND LIKE '%%'' at line 1


I see there is a problem with the quotes, the probleme is at the end LIKE '%", but my code is right. I hope so.
 
Share this answer
 
v2
Comments
Martin Jarvis 5-Jul-10 9:47am    
That looks like it's being cuased by your text fields being empty. % is a wildcard character so %% makes no sense. Maybe you could do a replace on your final string to replace '%%' with '%'.

You'll probably want to check that BETWEEN supports LIKE constraints. I don't think TSQL supports them.
Aciobanita Costel 6-Jul-10 2:55am    
I think that is the problem BETWEEN LIKE,

I try to make a select from database, to select all filds from to Data time,

i will try to find a other to do that.

tanks for reply.
I use to have this problem, but SQL support for sure the Like command.
This is what I’ve done:

LIKE '" + po + cbIMEI.Text + po + "'


Where 'po' is a global string variable that contain the text '%'

Hope this Help.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900