Beginner's question: C# visual studio .net 2003 and sql, how to select records based on pattern matching
Posted on 2005-04-05
I am learning C# using VS .net 2003 and want to know how to display records in an Access database based on specific search terms.
What I am using as a learning model is the following article in MSDN Library:
Walkthrough: Displaying Data in a Windows Form Using a Parameterized Query
The code to pass the parameter to MSDE to display only records with specific State (such as CA) is:
oleDbDataAdapter1.SelectCommand.Parameters["state"].Value = txtStateParameter.Text;
So far, I managed to use another Access database and search on another field and can pattern match using %SearchTerm% fine.
Now I want to improve this search. Let say when user enter "red shirt", I want to display records that has "red" and "shirt" in any order. Not just records that has "red shirt". How do I pass this to the sql select statement to achieve my result. I know how to split the search string to 2 strings "red" and "shirt".