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.
LVL 8
CamilliaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Miguel OzSoftware EngineerCommented:
Can you show the original solution/question?
My educated guess is:
int stepcompleted = 0;
try{
 //loop that increments stepcompleted++ when step is completed

}
catch(Exception ex)
{
   Debug.WriteLine(String.Format("Error msg:{0}, at step {1}", ex.Message, stepcompleted);
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CamilliaAuthor Commented:
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

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.