locked
Procedure Execution RRS feed

  • Question

  • User1979860870 posted

    Hi

      I have below code . I want even if error gets occurred in Procedure 1 , Procedure 2 should gets execute.

    public Form1()
            {
                InitializeComponent();
                string Cnn = ("Server=Demo;Database=Test;uid=sa;pwd=sa");
                con = new SqlConnection(Cnn);
                con.Open();
                Procedure1();

    Procedure2();

              }

    Thanks 

    Wednesday, December 30, 2020 7:17 AM

All replies

  • User753101303 posted

    Hi,

    Which kind of "error" could happen in Procedure1? Seems you are heading to using try-catch - C# Reference | Microsoft Docs but it seems a bad design.

    For example I see sometimes one that tries an insert and fallbacks to an update if it fails. It would be IMO much better to test for the primary or candidate key and act accordingly.

    Wednesday, December 30, 2020 10:21 AM