Last post Jan 10, 2017 06:57 AM by Mr.Torbati
Jan 09, 2017 05:38 PM|Mr.Torbati|LINK
I have Access database and text box for search in family name and show data in dataGridView.
I write query as flowing that shows result based exact family name, But I want to show family base a word that entered.
(For example: in result are showed = Schmidt, Schmidt junior, Schmidt senior when I enter Schmidt).
private void btnPersonalSearch_Click(object sender, EventArgs e)
string connStr = @"Provider=Microsoft.ACE.OLEDB.12.0; Data Source = ...";
string query = "select ID, name, family from UserId WHERE family Like '" + txtSfamily.Text + "' ";
using (OleDbConnection conn = new OleDbConnection(connStr))
using (OleDbDataAdapter adapter = new OleDbDataAdapter(query, conn))
DataSet ds = new DataSet();
dataGridView2.DataSource = ds.Tables;
Jan 09, 2017 05:42 PM|codemovement.pk|LINK
try using it like this
string query = "select ID, name, family from UserId WHERE family Like '%" + txtSfamily.Text + "%' ";
Jan 10, 2017 12:50 AM|oned_gk|LINK
string query = "select ID, name, family from UserId WHERE family Like '*" + txtSfamily.Text + "*' ";
Jan 10, 2017 06:57 AM|Mr.Torbati|LINK
Dear Nabeel Ilyas
Thanks for your help.
With the best wishes