i have using this code for searching in datagridview
dataGridView1.Rows.Clear();
SqlCommand cmd = new SqlCommand("select * from enquery where sname='" + textBox1.Text + "' or contectno='" + textBox1.Text + "' or courese='" + textBox1.Text + "'or remark='" + textBox1.Text + "' or edate='" + textBox1.Text + "' or id='" + textBox1.Text + "' or fudate='" + textBox1.Text + "' or fustatus='" + textBox1.Text + "' or cancel='" + textBox1.Text + "' ", con);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
object[] row = { dr[0], dr[1], dr[2], dr[3], dr[4], dr[5], dr[6], dr[7], dr[8] };
dataGridView1.Rows.Add(row);
}
con.Close();
this code is working if all the field in sql are same datatype but not working if those field are different data type , example sname is varchar contectno is bigint so it show exception , can anybody help me short out this problum.i have only one textbox and user can search by any field.

Rupali ShindeRank #539 · 4.5K reputationPosted Oct 1, 2015, 3:47 AM EDT
Manas MohapatraRank #182 · 13.2K reputationPosted Aug 6, 2015, 10:31 PM EDT
Nitin Sharma152 reputationPosted Sep 4, 2015, 10:37 PM EDT
Pankaj Kumar ChoudharyRank #80 · 24.4K reputationPosted Sep 4, 2015, 11:51 PM EDT
Nitin Sharma152 reputationPosted Oct 5, 2015, 12:49 AM EDT
Rupali ShindeRank #539 · 4.5K reputationPosted Oct 5, 2015, 2:36 AM EDT