Click to See Complete Forum and Search --> : Exception


malab
April 18th, 2005, 03:37 AM
Hi All,

try
{

con.open()
}
catch(Exception e )
{
e.Delete();

}

I am trying to open a database.If there is any error when i am opening that database,I wanted to delete that error.How to do that.Pls help me.
Thanks in advance.

Thanks and Regards,
Mala sri

cilu
April 18th, 2005, 04:07 AM
Why? Your program runs in a managed environment. Let the CLR delete it.

Anyway, if you catch a custom exception, that you coded, and it implements Dispose() (by implementing IDisposible interface) you may call Dispose(). There is no such thing as Delete().

cicciodinoto
April 18th, 2005, 04:11 AM
Hmmm... i suppose there is no need to clear an Exception. Better to notify user that DataBase was not open, and maybe WHY DataBase was not open, some sort of

Label1.Text = "DataBase Non Open! " + e.Message;

Ciiiiiiiiiiiiiiiiiii

mehdi62b
April 18th, 2005, 03:30 PM
if you wanted to stop throwing the exception


try
{
//...
}
catch(Exception e )
{
Exception exp=e;
}

Andy Tacker
April 19th, 2005, 03:15 AM
try
{
Open database
1: do something
}
catch (Exception)
{
Message box - oh my god...
}
finally
{
Message box... database isnt open... what to do now?
2: do something else with data
}

that's it... you dont have to worry about other things...
you should know that i you catch an excpetion while open... 1 will not be executed. and similarly, if in finally block... database is not open... 2: will throw another error/exception...