Link to home
Start Free TrialLog in
Avatar of Camillia
CamilliaFlag for United States of America

asked on

Related question - meaning of this solution

I accepted this solution thinking I understand the solution but now that I want to code it, i don't understand how to check the value...

This is the soution:
In the try declare an int stepcompleted = 0;
Increment it after each call.
Check its value if an exception is called.


My code is in the related question. I dont know how to do this: Check its value if an exception is called.
ASKER CERTIFIED SOLUTION
Avatar of Miguel Oz
Miguel Oz
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Camillia

ASKER

Sure, still working on this. This is what I have so far but I still not sure how to capture that "stepCompleted" value. I think having "throw" will prevent it from capturing that value...

code is bit long but it's simple. Thanks so much for looking at it..been at it for 4 hours now :(

I have other catch but removed them to make it shorter to post here.
protected void btnTestSave_Click(object sender, EventArgs e)
    {
        if (!Page.IsValid)
        {
        }
        else
        {
            try
            {
               int step = Save();
                Response.Redirect("thank-you.aspx",false); //payment will go here
            }

          
            catch (SqlException ex)
            {
                
                lblMsg.Text = "An error occured. Please contact Retina Health";
                ExceptionError(ex.Message, ex.StackTrace,"SQL Exception");
               
            }
           
        }
    }

-------------------------------
 private int Save()
    {
        using (TransactionScope scope = new TransactionScope())
        {
            int stepCompeleted = 0;
            try
            {
                
                Sign_UpData sd = new Sign_UpData();
                sd.Connection.Open();

                int businessNameId = SaveDescription(sd);
                stepCompeleted = stepCompeleted + 1;

                SaveContactPerson(sd, businessNameId);
                stepCompeleted = stepCompeleted + 1;

                 SaveOfficeLocation(sd, businessNameId);
                 stepCompeleted = stepCompeleted + 1;

                SaveHCProviderInformation(sd,businessNameId);
                stepCompeleted = stepCompeleted + 1;

                SaveOfficerUserName(sd, businessNameId);
                stepCompeleted = stepCompeleted + 1;

                
                scope.Complete();
            }

           
            catch (SqlException ex)
            {
                throw;
            }
            
           

            return stepCompeleted;


        }

    }

Open in new window