locked
Success Message RRS feed

  • Question

  • User-1499457942 posted

    Hi

     I have below code and i want if Stored Procedure is successfully processed then message should get display ;Successfully Done

    SqlCommand cmd = new SqlCommand("Sp_Emp", con);
    cmd.CommandType = CommandType.StoredProcedure;

    cmd.executenonquery()

    Thanks

    Sunday, November 4, 2018 12:21 PM

Answers

  • User1120430333 posted

    Well put the code in a try/catch around the code. If the execution of the sproc is successful, the successful path of the try/catch path will be taken where you can display a success message, otherwise, the catch exception path is taken and basically whatever the sproc was doing blew-up and an exception is thrown.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, November 4, 2018 1:28 PM

All replies

  • User1120430333 posted

    Well put the code in a try/catch around the code. If the execution of the sproc is successful, the successful path of the try/catch path will be taken where you can display a success message, otherwise, the catch exception path is taken and basically whatever the sproc was doing blew-up and an exception is thrown.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, November 4, 2018 1:28 PM
  • User475983607 posted

    Hi

     I have below code and i want if Stored Procedure is successfully processed then message should get display ;Successfully Done

    SqlCommand cmd = new SqlCommand("Sp_Emp", con);
    cmd.CommandType = CommandType.StoredProcedure;

    cmd.executenonquery()

    Thanks

    SqlCommand.ExecuteNonQuery returns the number of records affected.  The code sample provided is not enough information to provide an accurate solution or answer to this question.  Please read the openly published documentation which has sample source code that explains use.

    Sunday, November 4, 2018 1:40 PM
  • User753101303 posted

    Hi,

    ExecuteNonQuery() returns how many rows are processed :

    if (cmd.ExecuteNonQuery()!=0) Result.Text="Successfully Done";

    Sunday, November 4, 2018 1:59 PM