Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6255875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:26:46+00:00 2026-05-24T14:26:46+00:00

Been through my textbook, but I’m still having problems with catching an inner exception

  • 0

Been through my textbook, but I’m still having problems with catching an inner exception as I try to add a record to the database. What is the proper syntax for catching an InnerException in my class?

The inner expection is being thrown on the db.SaveChanges. Here is the code in my ‘addReviews.cs’ class file to add the record:

  public void addReview(int restId, int timeID, string dateValue, string describe, int cuisineId, int serviceId, int ambianceId, string memberId)
    {
        REVIEW addReview = new REVIEW();
        addReview.REVIEW_DATE = Convert.ToDateTime(dateValue);
        addReview.REVIEW_DATE_SUBMITTED = DateTime.Today;
        addReview.REVIEW_DESC = describe;
        addReview.TIME_ID = timeID;
        addReview.REVIEWER_ID = 1;
        addReview.FOOD_ID = cuisineId;
        addReview.SERVCE_ID = serviceId;
        addReview.AMBIENCE_ID = ambianceId;
        addReview.REST_ID = restId;
        addReview.PRICE_ID = 1;

        //Add record to database
        db.AddToREVIEWs(addReview);
        db.SaveChanges();
    }

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T14:26:47+00:00Added an answer on May 24, 2026 at 2:26 pm

    Try this out:

    try
    {
      db.SaveChanges();
    }
    catch(ApplicationException exception)
    {
       // just log and throw out
       System.Diagnostics.Debug.WriteLine(
                  String.Concat(
                       "EXCEPTION: ", 
                       exception.ToString));
    
       if (exception.InnerException != null)
       {
          System.Diagnostics.Debug.WriteLine(
                   String.Concat(
                      "INNER EXCEPTION: ", 
                      exception.InnerException.ToString));
       }
    
       throw;
    }
    

    PS: try to catch more specific exception, in your case it worth to catch SqlException as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been through the sed one liners but am still having trouble with
I have been through a fair bit of the code in modules/database/classes/ but still
So, I've been through the BlackBerry API, and the online documentation, but I'm having
I'm looking at this code and have been through the docs but still don't
I have been through every option to try to find a way to get
I have been using Jira since 6months but haven;t been through any document related
I've been through a bunch of examples and other questions on SO, but I'm
I've been through the forums and read many posts relating to my question, but
I've been through the MSDN chapter on this at least 50 times. But I'll
I know this has been discussed a number of times but I've been through

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.