Click here to Skip to main content
15,888,610 members
Home / Discussions / C#
   

C#

 
GeneralRe: integrate security access cord project Pin
Vasudevan Deepak Kumar19-Sep-12 10:59
Vasudevan Deepak Kumar19-Sep-12 10:59 
GeneralRe: integrate security access cord project Pin
Paul Conrad19-Sep-12 17:38
professionalPaul Conrad19-Sep-12 17:38 
QuestionThe API Pin
mauricemcse17-Sep-12 10:32
mauricemcse17-Sep-12 10:32 
AnswerRe: The API PinPopular
Andrei Straut17-Sep-12 10:49
Andrei Straut17-Sep-12 10:49 
AnswerRe: The API Pin
Mycroft Holmes17-Sep-12 20:18
professionalMycroft Holmes17-Sep-12 20:18 
GeneralRe: The API Pin
Andrei Straut17-Sep-12 20:26
Andrei Straut17-Sep-12 20:26 
AnswerRe: The API Pin
V.17-Sep-12 20:30
professionalV.17-Sep-12 20:30 
AnswerRe: The API Pin
Pete O'Hanlon17-Sep-12 22:26
mvePete O'Hanlon17-Sep-12 22:26 
AnswerRe: The API Pin
Richard MacCutchan17-Sep-12 22:41
mveRichard MacCutchan17-Sep-12 22:41 
QuestionC# access a file Pin
classy_dog17-Sep-12 8:37
classy_dog17-Sep-12 8:37 
AnswerRe: C# access a file PinPopular
Pete O'Hanlon17-Sep-12 9:01
mvePete O'Hanlon17-Sep-12 9:01 
GeneralRe: C# access a file Pin
classy_dog17-Sep-12 17:02
classy_dog17-Sep-12 17:02 
GeneralRe: C# access a file Pin
Pete O'Hanlon17-Sep-12 22:05
mvePete O'Hanlon17-Sep-12 22:05 
AnswerRe: C# access a file Pin
PIEBALDconsult17-Sep-12 17:00
mvePIEBALDconsult17-Sep-12 17:00 
QuestionInternal connection fatal error!! why?!! Pin
Jassim Rahma17-Sep-12 5:12
Jassim Rahma17-Sep-12 5:12 
AnswerRe: Internal connection fatal error!! why?!! Pin
Pete O'Hanlon17-Sep-12 6:09
mvePete O'Hanlon17-Sep-12 6:09 
GeneralRe: Internal connection fatal error!! why?!! Pin
Andrei Straut17-Sep-12 6:14
Andrei Straut17-Sep-12 6:14 
AnswerRe: Internal connection fatal error!! why?!! Pin
Emmanuel Medina17-Sep-12 7:43
professionalEmmanuel Medina17-Sep-12 7:43 
GeneralRe: Internal connection fatal error!! why?!! Pin
Jassim Rahma17-Sep-12 7:56
Jassim Rahma17-Sep-12 7:56 
GeneralRe: Internal connection fatal error!! why?!! Pin
Emmanuel Medina17-Sep-12 8:12
professionalEmmanuel Medina17-Sep-12 8:12 
GeneralRe: Internal connection fatal error!! why?!! Pin
Jassim Rahma17-Sep-12 8:18
Jassim Rahma17-Sep-12 8:18 
GeneralRe: Internal connection fatal error!! why?!! Pin
Andrei Straut17-Sep-12 8:25
Andrei Straut17-Sep-12 8:25 
GeneralRe: Internal connection fatal error!! why?!! Pin
PIEBALDconsult17-Sep-12 8:42
mvePIEBALDconsult17-Sep-12 8:42 
AnswerRe: Internal connection fatal error!! why?!! Pin
PIEBALDconsult17-Sep-12 8:39
mvePIEBALDconsult17-Sep-12 8:39 
AnswerRe: Internal connection fatal error!! why?!! Pin
jschell17-Sep-12 8:43
jschell17-Sep-12 8:43 
In general a bad idea all around.

If an exception occurs you do NOT know why it occurred.
It is possible that almost anything afer that point will cause another exception.

Thus your code should be structured like this.

try
{
  ...
  command.Dispose();
  connect.Close();
  // At this point ALL resources should be cleaned up for
  // a normal exit.
}
catch(Exception e)
{
   // Clean up resources for abnormal exit.

   // REPORT THE EXCEPTION!!!!!
   try
   {
     command.Dispose();
   }
   catch(Exception)
   {
     // Ignore it because we already have an exception
   }

   try
   {
     connection.Close();
   }
   catch(Exception)
   {
     // Ignore it because we already have an exception
   }

   // Repeat try/catch for all other resources.
 }  // End of first try

 // There is NO finally block.  All connection
 // resources were cleaned up by regular process flow or exception block.
 // finally could be used for resources that were NOT connection related.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.