ANKIT SHUKLA

ANKIT SHUKLA

  • NA
  • 173
  • 8k

There is already an open DataReader associated with this cmd

Jun 6 2018 12:34 PM
 
Given this Error On Post Method. 
 
 
[HttpPost]
public ActionResult Index(LoginModel model)
{
int id = model.UniqueId;
string Connect = model.Link;
DataTable dtbl = new DataTable();
using (SqlConnection con = new SqlConnection(connectionString2))
{
con.Open();
string qry = "select * from AppMasterTable where SchoolCode='" + id + "' ";
SqlCommand cmd = new SqlCommand(qry, con);
SqlDataReader sdr = cmd.ExecuteReader();
SqlDataAdapter sqlda = new SqlDataAdapter(qry, con);
if (sdr.Read())
{
sqlda.Fill(dtbl);
if (dtbl.Rows.Count == 1)
{
model.Link = dtbl.Rows[0][2].ToString();
}
return RedirectToAction("Index", "StudentProfile", new { ids = model.Link });
}
else
{
ViewBag.id = model.UniqueId;
ViewBag.Message = "Login Error..!!";
}
con.Close();
}
return View();
}
 

Answers (2)