Results 1 to 3 of 3

Thread: [RESOLVED] [2.0] Error Ex.Message

  1. #1

    Thread Starter
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Resolved [RESOLVED] [2.0] Error Ex.Message

    Hi all
    I am getting some error message at the bold part, error is
    The type cougnt or throw must be derived from the system.exception
    how to correct it.
    Thanks


    Code:
    private Boolean ExecuteQuery(string queryString) 
            {
                SqlCommand SqlCommand = new SqlCommand();
                try
                {
                    SqlCommand = ReturnCommand();
                    SqlCommand.CommandText = queryString;
                    SqlCommand.ExecuteNonQuery();
                }
                catch(Exception Ex) 
                {
                    throw Ex.Message;            }//The type cougnt or throw must be derived from the system.exception
            }

  2. #2

    Thread Starter
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: [2.0] Error Ex.Message

    Ok get the solution

    vb Code:
    1. catch(Exception Ex)
    2.             {
    3.                 throw (Ex);
    4.             }

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [RESOLVED] [2.0] Error Ex.Message

    Just note that there's absolutely no point catching an exception just to rethrow it again. If you aren't going to do anything in the catch block then it serves no purpose UNLESS you also have a finally block.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width