Reputation: 11717
I have a database (DB) with a table "Products" in it. A user can store in it in. Suppose different users are storing the data as "DELL", "Dell", "D-E-L-L", "D E L L" and similar to it in many ways. I have all these data in a Datagridview. Now I want to make a Like search in the Datagridview. How to achieve it by displaying all the records of "Dell". Any help will be highly appreciated. Thanks. I am using Winforms, C# 4.0.
Upvotes: 1
Views: 1002
Reputation: 2044
If this is an application which is meant to track products and you have control over it, then you may wish to start normalizing your list of manufacturing companies (you mentioned the data was 'Dell' so I assume you are not referencing a column for the product name). Create a 'Company' table and replace the manufacturer column (if that is what it is called) with a companyId that references the Company table. That way you can build a search based off of a drop down list which shows the names of all of the companies (or where they can type in a LIKE search for the name, but at least the results would be based off of a normalized-ish list).
Alternatively you will need to manage your data and will have to have someone responsible for going in to sort the data in an edit control to replace all the "DELL", "D-E-L-L" and "De ll"s with "Dell".
You can use a soundex search to get somewhat similar results if your names are still close (but not close enough to use a LIKE search).
The reason searches from google work using LIKE style queries is because they use heuristics and algorythms to analyse relationships and predict what you want. A simple LIKE query is not going to analyze similarity patterns. Soundex searches are close, but probably still not what you want.
Upvotes: 2