• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 216
  • Last Modified:

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.
0
Camillia
Asked:
Camillia
1 Solution
 
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now