I solved the issue!!!! Here is my updated code:
protected void TextBoxUNITID_TextChanged(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HotConnectionString"].ConnectionString);
con.Open();
SqlConnection con2 = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HotConnectionString"].ConnectionString);
con2.Open();
if (true)
{
SqlCommand level = new SqlCommand("select UNITID ,INST_ID from Table442012 where UNITID = @UNITID AND INST_ID = @INST_ID", con);
level.Parameters.Add(new SqlParameter("UNITID", TextBoxUNITID.Text));
level.Parameters.Add(new SqlParameter("INST_ID", TextBoxINST_ID.Text));
SqlCommand scmd = new SqlCommand("Select INST_ID, UNITID, ASTUDENTS, ACOMPLETED, ATRANSFERS, BSTUDENTS, BCOMPLETED, BTRANSFERS, YEAR from Table442012 where UNITID = @TextBoxUNITID", con);
SqlCommand scmd2 = new SqlCommand("Select INST_ID, UNITID, ASTUDENTS, ACOMPLETED, ATRANSFERS, BSTUDENTS, BCOMPLETED, BTRANSFERS, YEAR from Table452013 where UNITID = @TextBoxUNITID", con2);
scmd.Parameters.Add(new SqlParameter("@TextBoxUNITID", TextBoxUNITID.Text));
scmd2.Parameters.Add(new SqlParameter("@TextBoxUNITID", TextBoxUNITID.Text));
SqlDataReader dr = scmd.ExecuteReader();
SqlDataReader dr2 = scmd2.ExecuteReader();
if (dr.Read())
if (dr2.Read())
{
TextBoxLYTNUGSC.Text = dr["ASTUDENTS"].ToString();
TextBoxLYTNUGSCD.Text = dr["ACOMPLETED"].ToString();
TextBoxLYTTOUG.Text = dr["ATRANSFERS"].ToString();
TextBoxLYTNGSC.Text = dr["BSTUDENTS"].ToString();
TextBoxLYTNGSCD.Text = dr["BCOMPLETED"].ToString();
TextBoxLYTTOG.Text = dr["BTRANSFERS"].ToString();
TextBoxINST_ID.Text = dr["INST_ID"].ToString();
TextBoxLYEAR.Text = dr["YEAR"].ToString();
TextBoxTNUGSC.Text = dr2["ASTUDENTS"].ToString();
TextBoxTNUGSCD.Text = dr2["ACOMPLETED"].ToString();
TextBoxTTOUG.Text = dr2["ATRANSFERS"].ToString();
TextBoxTNGSC.Text = dr2["BSTUDENTS"].ToString();
TextBoxTNGSCD.Text = dr2["BCOMPLETED"].ToString();
TextBoxTTOG.Text = dr2["BTRANSFERS"].ToString();
TextBoxINST_ID.Text = dr2["INST_ID"].ToString();
TextBoxYEAR.Text = dr2["YEAR"].ToString();
TextBoxTNUGSC.Focus();
}
dr.Close();
con.Close();
dr2.Close();
con2.Close();
}
}