i am want to search record from two columns ... from one text box and one button .. i am getting this eror
There is already an open DataReader associated with this Command which must be c
protected void Button1_Click(object sender, EventArgs e)
{
try
{
con.Open();
SqlCommand cmd = new SqlCommand( "SELECT * FROM KSMCemp_data WHERE National_ID =" + TextBox1.Text , con);
SqlDataAdapter da1 = new SqlDataAdapter(cmd);
SqlDataReader Dr = cmd.ExecuteReader();
DataSet ds = new DataSet();
if (Dr.Read())
{
da1.Fill(ds);
GridView2.DataSource = ds;
GridView2.DataBind();
con.Close();
Dr.Close();
}
else
{
con.Close();
con.Open();
DataSet ds2 = new DataSet();
SqlCommand cmnd = new SqlCommand("SELECT * FROM KSMCemp_data WHERE serial_no =" + TextBox1.Text, con);
SqlDataAdapter da2 = new SqlDataAdapter(cmnd);
SqlDataReader Dr1 = cmd.ExecuteReader();
if (Dr1.Read())
{
da2.Fill(ds2);
GridView2.DataSource = ds2;
GridView2.DataBind();
con.Close();
Dr1.Close();
}
else
{
Message("Reference ID Not Found", this);
}
}
}
catch
{
Message("ID Not Found", this);
}
}