求帮忙
为什么异常不能捕捉到?try
{
if (RadioButton1.Checked)
{
string str = "select * from Book where BookName='" + this.TextBox1.Text + "'";
DataTable dt = DB.getdt(str);
if (dt.Rows.Count > 0)
{
Session["name"] = this.TextBox1.Text.Trim();
Response.Write("<script>location='shumu1.aspx';</script>");
}
}
else if (RadioButton2.Checked)
{
string str = "select * from Book where BookID='" + this.TextBox1.Text + "'";
DataTable dt = DB.getdt(str);
if (dt.Rows.Count > 0)
{
Session["id"] = this.TextBox1.Text;
Response.Write("<script>location='shumu.aspx';</script>");
}
}
}
catch (Exception ex)
{
Response.Write("<script>alert(" + ex.Message + ")</script>");
//Console.WriteLine("an error ourced");
} --------------------编程问答-------------------- 你就代表没错误啊 --------------------编程问答-------------------- 那就没有异常啊 --------------------编程问答-------------------- 是故意制造异常却不能捕捉 --------------------编程问答--------------------
有异常可以捕捉,没有异常可以先制造异常然后再捕捉。
补充:.NET技术 , ASP.NET