My program runs, client enters what he is looking for and it searches it in the SQL database. When he clicks on search, it appears in a datagridview.
I want the client to enter any word, beginning or end of a word and instead of looking in one column it will look in the entire table.
How do I program that?
clsdatasource.search gets what's in the textbox and stores it in a variable.
DataView myview = new DataView(mytable);
myview.RowFilter = "CUSTOMER='" + clsDataSource.search + "'";
dataGridView1.DataSource = myview;
What I tried:
for (int i = 0; i < myset.Tables[0].Columns.Count; i++) {
DataRow[] MyDR = myset.Tables[0].Select(myset.Tables[0].Columns[i].ToString() + "='" + clsDataSource.search + "'");
if (MyDR.Length > 0) {
dataGridView1.DataSource = myview;
}
}
Try this:
To search in all columns of different types, I convert them to strings. Then use the
like
operator. And, finally, combine withor
.