Click here to Skip to main content
15,891,513 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi there, I have a visual basic windows form with a datagrid and a picturebox.
The datagrid is hooked up to a database that contains three fields :

SQL
Id int
Description varchar(100)
AbsPath varchar(200)


when the form loads the picturebox is filled with a photo image from AbsPath.
Nothing special about that in its self.

I have configured a query to search description like this:

SQL
SELECT        id, Description, AbsPath
    FROM            TablePhoto
    WHERE        (Description LIKE @Description + N'%')


The problem is the search only matches from the left of 'description"

So if I enter "white" for the search I get

white rose
white flower
etc

If I enter "flower" I get nothing

According to what I have read I should be able to use the LIKE wildcard %% so the search will match "flower" within the description so I should get:

white flower<br />
Blue flower<br />
etc


But what is the correct syntax to use, I have tried various combinations but the query builder dosnt seem to like it.

Thanks in advance for any help
Posted
Updated 11-Oct-11 22:44pm
v2

SQL
SELECT            id, Description, AbsPath
     FROM                  TablePhoto
     WHERE            (Description LIKE '%'+@Description+'%')
 
Share this answer
 
v2
Comments
hamed2011 21-Feb-15 3:42am    
tnx a lot guys work like charm!!
select id, Description, AbsPath from TablePhotowhere Description LIKE '%' + @Description+'%'


try this


Regards,

Anilkumar.D
 
Share this answer
 
v2

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