Hey, I'm programming in vb.net using vs2008 and sqlexpress 2005. I just need a little insight on where to go from here to do what I wanna do, so here I go:
I have a program that draws data from a dataset into a datagridview.
I also have a search feature, as you can see, that uses the following sql code to search the database and then re-fill the dataset with the newly filtered data.
It searches certain columns for criteria like this:
If I search for "power" it will return the row of the searchable columns (Frame, Stock Num, Color) that the query matches. Seems to work fine.
THE PROBLEM:
As you can see, one of the frames has a color of "crater". I want to find a power ranger frame with the color crater. So naturally,
Oops, this is because it is searching Frame, Stock Num, or color for "%power crater%".
I was wondering what the best way of making this work is? Should I use an instr function and divide the search string into separate variables and searched based on those terms? But how would I even do that, if I don't know how many parameters there are, how can I construct the sql query?
I just need some insight on how to fix this search to be able to search multiple columns, with multiple parameters, or if theres a better way to do it it'd be greatly appreciated
Thanks!
I have a program that draws data from a dataset into a datagridview.
I also have a search feature, as you can see, that uses the following sql code to search the database and then re-fill the dataset with the newly filtered data.
VB.NET:
SELECT ID, Frame, [Stock Num], Type, [Insurance Code], Mfgr, Color, Size, Cost, Retail, [% Markup], [Qty on Hand], [Reorder Point], [Ordered From], [Qty on Order], [Qty to Order], [Date Ordered], [Date Recieved], [Order Initials], [Recieve Initials], [Date Sold], BarCode FROM dbo.Materials WHERE Frame like '%'+@search+'%' or [Stock Num] like '%'+@search+'%' or Color like '%'+@search+'%'
It searches certain columns for criteria like this:
If I search for "power" it will return the row of the searchable columns (Frame, Stock Num, Color) that the query matches. Seems to work fine.
THE PROBLEM:
As you can see, one of the frames has a color of "crater". I want to find a power ranger frame with the color crater. So naturally,
Oops, this is because it is searching Frame, Stock Num, or color for "%power crater%".
I was wondering what the best way of making this work is? Should I use an instr function and divide the search string into separate variables and searched based on those terms? But how would I even do that, if I don't know how many parameters there are, how can I construct the sql query?
I just need some insight on how to fix this search to be able to search multiple columns, with multiple parameters, or if theres a better way to do it it'd be greatly appreciated
Thanks!