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 8330333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:05:33+00:00 2026-06-09T02:05:33+00:00

I am using ASP.NET/C# . Here is an example where I am updating some

  • 0

I am using ASP.NET/C#.

Here is an example where I am updating some information in database using lambda expression.

try
{
    using (var db = new DataClasses1DataContext())
    {
        var logSubGroup = db.sys_Log_Account_SubGroups
             .SingleOrDefault(subGroup => subGroup.cSubGroupName.Equals(subGroupName));
        logSubGroup.cRejectedBy = rejectedBy;
        logSubGroup.dRejectedOn = DateTime.Now;
        logSubGroup.cAuthorizedStatus = "Rejected";
        db.SubmitChanges();
    }
}
catch (Exception ex)
{
}

As you can see I am not doing anything inside catch() block.

I know this is a terrible way of using try catch.

Can anyone just help me to use try catch block in a correct manner.

I am just clueless as to what must come inside the catch block.

Any suggestions are welcome.

  • 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-06-09T02:05:35+00:00Added an answer on June 9, 2026 at 2:05 am

    You should ideally handle the error so that your application can recover from it, at the very least though, you should log it. You should never just swallow it. Also, you shouldn’t handle an exception that you don’t expect or can’t handle. For example, when opening a file, a FileNotFoundException can be expected and handled, for example by displaying a warning and letting the user pick another file.

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

Sidebar

Related Questions

I am new here so hello. I am using ASP.NET 4 and I am
I'm using Unity with an Asp.net MVC 3 app. Here is some code running
I'm using ASP.NET MVC 2 and here's the issue. My View Model looks something
I am using ASP.NET page methods with jQuery. Here is my code, $.ajax({ type:
I'm using the ASP.Net SqlMembershipProvider to manage my users. Here is my config: <membership
Let me first put the code snippets here. I am just using the ASP.NET
Here I am working with asp.net web application, I am using 2 facebook plugin
I an using jQuery validation plugin in asp.net 4.0 application. Click here to see
Using ASP.net and c# using visual studio 2010 Hi all, I hope some one
I am using ASP.NET MVC2 on top of a MySQL database in VS2008. I

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.