The code was executing fine but now an exception is generated: "exc = {Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.}"
Code:
protected void bsin_Click(object sender, EventArgs e)
{
con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
com = new SqlCommand("Select *From register Where loginname=@loginname And password=@password", con);
com.Parameters.Add("@loginname", SqlDbType.NVarChar).Value = txtun.Text;
com.Parameters.Add("@password", SqlDbType.NVarChar).Value = txtpass.Text;
try
{
if (con.State == ConnectionState.Closed)
con.Open();
dr = com.ExecuteReader();
if (dr.Read())
{
Session["username"] = txtun.Text;
Session["password"]=txtpass.Text;
lplwronguserid.Visible = false;
Response.Redirect("home.aspx");
}
else
{
lplwronguserid.Text = "Wrong Password OR UserID*";
//Response.Write("Wrong Password OR UserID");
}
}
catch (Exception exc)
{
}
finally
{
con.Close();
}
}
Comment