private void btnSearch_Click(object sender, EventArgs e) { try { string commaDelimited = textBox1.Text; string[] year = commaDelimited.Split(new char[] { }); ///////////////////////////////////////// //string[] r = { "TV", "Radio", "Coal" }; string filter = string.Empty; foreach (string name in year) { if (filter.Length > 0) { filter += ","; } filter += string.Format("'{0}'", name); } SqlDataAdapter adp; DataSet ds = new DataSet(); adp = new SqlDataAdapter("Select * from EMP_DET where FName IN (Like '%(" + filter + ")%')", con); adp.Fill(ds, "EMP_DET"); dataGridView1.DataSource = ds.Tables[0].DefaultView; } catch { } }
SELECT * FROM EMP_DET WHERE FName LIKE %word1% OR FName LIKE %word2%
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)