Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
dr = MYDBConnection.ExecuteReader_Query(@"select IE_VECHICLE_CODE from IE_VECHICLE_MASTER where VEHICLE_MAKE='"+objDetails.VechicleMake+"' and VEHICLE_MODEL='"+objDetails.VechicleModel+"' and VEHICLE_SUBTYPE like '"+objDetails.VechicleSubtype+"'");

i want to write a like command for objDetails.VechicleSubtype could any one help me.
but i am getting like in query
C#
select IE_VECHICLE_CODE from IE_VECHICLE_MASTER where VEHICLE_MAKE='MARUTI' and VEHICLE_MODEL='SWIFT' and VEHICLE_SUBTYPE like '%'LXI'%'

Thanks and Regards in adv,

Rahul.
Posted
Updated 18-Sep-13 0:07am
v3

LIKE requires wildcard characters, in the same what the Windows File names can:
"*.jpg" for example returns all files ending with ".jpg"

For SQL the wild card is '%':

SQL
SELECT * FROM MyTable WHERE UserName LIKE '%fred%'
will return:
fred
alfred
freda
hello, my name is fred the dwarf warrior
 
Share this answer
 
It looks like you need to add the wildcard operator (%)into your like clause.
... something like this:

C#
dr = MYDBConnection.ExecuteReader_Query(@"select IE_VECHICLE_CODE from IE_VECHICLE_MASTER where VEHICLE_MAKE='"+objDetails.VechicleMake+"' and VEHICLE_MODEL='"+objDetails.VechicleModel+"' and VEHICLE_SUBTYPE like '%"+objDetails.VechicleSubtype+"%'");
 
Share this answer
 
Comments
naveen pallela 19-Sep-13 4:15am    
thank u hypermellow...its working now
hypermellow 19-Sep-13 4:17am    
excellent, glad your all sorted now. :)

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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