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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:06:19+00:00 2026-05-28T06:06:19+00:00

When i use the below function its showing the error message but still it

  • 0

When i use the below function its showing the error message but still it give a error saying that the exception not unhandled. why is it?

Public Function DepartmentDelete(ByVal DepartmentID As Integer) As DataTable

    Try
        Using con As New SqlConnection(CMClass.GetConnectionString())
            Dim ds As DataTable = New DataTable
            con.Open()
            Dim command As SqlCommand = New SqlCommand("Department_Delete", con)
            command.Parameters.AddWithValue("@DepartmentID", DepartmentID)
            command.CommandType = CommandType.StoredProcedure
            Dim adapter As SqlDataAdapter = New SqlDataAdapter(command)
            Dim table As DataTable = New DataTable
            adapter.Fill(ds)
            Return ds
            con.Close()
        End Using
    Catch ex As SqlException
                 Throw New Exception(MsgBox(ex.Message))
        End
    End Try

End Function
  • 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-28T06:06:20+00:00Added an answer on May 28, 2026 at 6:06 am

    You exception handler is correctly catching the SQLException.

    The problem is in the following line in your handler:

    Throw New Exception(MsgBox(ex.Message))
    

    If you want the message box, then just use

    MsgBox(ex.Message)
    

    If you then want to bubble the exception you should then use the line

    Throw
    

    Don’t put the ex on the end of the Throw as this creates a new exception (specifically the full stacktrace) instead of rethrowing the old one, thereby masking some details of the actual problem.

    In addition. If you do choose to rethrow the exception, you then need to catch it again somewhere further up the stack, otherwise you’ll still get the unhandled exception messages.

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

Sidebar

Related Questions

I'm trying to use the code below, but it's not working: UPDATED WORKING: $(document).ready(function()
When I use the code below its alerting a blank value? why is that?
I typically use the below function to return the root URL if I ever
How to Remove Badge from the tabbar item i had use below code but
Normally I use the below code, but is there a better way? lastOfMonth =
Is better to use the below statement Convert.ToInt32(0 + stringValue) If not then why?
I use the line below in my C# winform app, this works great but
When I try to use the code below I get a duplicate variable error
When i use appendBox function below, first time it works fine and the same
(Important: See update below.) I'm trying to write a function, import_something , that will

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.