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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:46:45+00:00 2026-05-30T16:46:45+00:00

Hello I have a regular WinForm that calls this: private void childDirectoryToolStripMenuItem_Click(object sender, EventArgs

  • 0

Hello I have a regular WinForm that calls this:

private void childDirectoryToolStripMenuItem_Click(object sender, EventArgs e)
{
     try
     {
         SQL.createTable("childDirectory"); //THIS LINE
     }
     catch(SystemException ecp)
     {
         MessageBox.Show(string.Format("An error occurred: {0}", ecp.Message));
     }
}

and have a class named “SQL”. The C# class cannot throw a messageBox to the user, only Console.WriteLine:

static public void createTable(string tableToCreate)
        {
            try
            {
                .
                .
                .
                .
            }
            catch (SqlException exp)
            {
                Console.WriteLine("Database not created: " + exp.Message, "Error");
            }
        }

How can I throw this SqlExecption back in the Form.cs call? Sorry if my wording is wrong, hopefully you can understand what I’m trying to do.

  • 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-30T16:46:46+00:00Added an answer on May 30, 2026 at 4:46 pm
        static public void createTable(string tableToCreate)
        {
            try
            {
                .
                .
                .
                .
            }
            catch (SqlException exp)
            {
                Console.WriteLine("Database not created: " + exp.Message, "Error");
                throw exp;
            }
        }
    

    And catch it with:

     private void childDirectoryToolStripMenuItem_Click(object sender, EventArgs e)
     {
         try
         {
              SQL.createTable("childDirectory"); //THIS LINE
         }
         catch(SystemException ecp)
         {
            MessageBox.Show(string.Format("An error occurred: {0}", ecp.Message));
         }
         catch (SqlException exp)
         {               
    
         }
     }
    

    But unless it is necessary you don’t need to catch exception in called method if you catch it in calling method.

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

Sidebar

Related Questions

Hello I have this list that i am working on. When i move the
I have a file that contains this: <html> <head> <title> Hello! - {{ today
Hello friends, I have a string like /Date(1312628727617+0000)/ and this regular expression convert into
I have a regular expression as follows: ^/[a-z0-9]+$ This matches strings such as /hello
Hello we have an SQL server application running over a low bandwith connection. We
Hello I have the following code namespace ConsoleApplication2 { class Program { static void
Hello I have been having trouble with this for a while now. I have
Hello i have this form filling javascript: function onLine(code,nn) { document.writeform.bericht.value+=code; document.writeform.bericht.focus(); document.writeform.nickname.value+=nn; write1();
I have been using this rule: RewriteRule ^([^\.]+)/?$ index.php?page=$1 [L] Which will turn example.com/page/hello
Hello I have a question with javascript form validation and regular expressions. Below is

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.