I'm a beginner in .net programming environment.I am using c#.
i have a text box(txtSearchKey) for user to enter the text key.
i have a combo box(cmbSearchBy) to specify in which field of employee table ,search key should be used to retrieve data.
when i use the above code i get with all fields and a blank record,even when i tried with all fields.
Should i use cmd.ExecuteReader();,If so how?.
Plase help me out.
SqlCommand cmd = new SqlCommand("Select * from employees where '"+cmbSearchBy.SelectedItem+"' = '"+txtSearchKey.Text+"' ", newcon);
int result=Convert.ToInt32(cmd.ExecuteNonQuery());
SqlDataAdapter da=new SqlDataAdapter(cmd);
DataSet ds =new DataSet();
da.Fill(ds);
dgv1.DataSource=ds.Tables[0].DefaultView;