locked
I want to show the excetion in message box in asp.Net webpage RRS feed

  • Question

  • User-1106072574 posted

    try

    {

    string str = "insert into employee(empid,empname,empgrade,empdept,empsal) values(" + TextBox1.Text + ",'" + TextBox2.Text + "','" + TextBox3.Text + "'," + TextBox4.Text + "," + TextBox5.Text + ")";SqlCommand cmd = new SqlCommand(str, cn);

    cn.Open();

    cmd.ExecuteNonQuery();

    }

    catch (Exception ee)

    {

    Response.Write(ee.Message);

    }

     I tried it using javascript but Iam getting the message What I wrote ,but I want  to get the returned exception.

    could any body help me out from this ..

    regards

    kapil.....................

     

     

    Thursday, August 30, 2007 1:27 AM

All replies

  • User-821857111 posted

    try

    {

    string str = "insert into employee(empid,empname,empgrade,empdept,empsal) values(" + TextBox1.Text + ",'" + TextBox2.Text + "','" + TextBox3.Text + "'," + TextBox4.Text + "," + TextBox5.Text + ")";SqlCommand cmd = new SqlCommand(str, cn);

    cn.Open();

    cmd.ExecuteNonQuery();

    }

    catch (Exception ee)

    { 

            Page.ClientScript.RegisterStartupScript(this.GetType(), "PopupScript", "alert('" + ee.Message + "');", true);

    }

     

     

    Thursday, August 30, 2007 6:03 AM