Jump to content

Exeption Variable

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
junelis

junelis

    Newbie

  • Members
  • Pip
  • 1 posts
I am new at C# and can`t find how to check if variable is defined or exist.
This is what I want to do:

try
            {
                //some sql insert query here       
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message);
            }
            finally
            {
                //here I want to check that "Exception er" is defined or exist or value is not null
                   if is not defined or not exist or value is null
                   than messagebox show some message
            }
         }

Best regards.

Edited by Jaan, 18 March 2010 - 06:56 AM.
Please use code tags when you are posting your codes!


#2
Davide

Davide

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 506 posts
I don't think you can use both catch and finally.
Anyway, show the message box in the try section if the code works, and show a message box in the catch section if the code doesn't work.
Are you a newbie programmer trying to learn C#? Check out my small tutorial: Visual C# Programming Basics