Click here to Skip to main content
15,903,856 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# and Power Point Pin
PDTUM3-May-11 13:01
PDTUM3-May-11 13:01 
GeneralRe: C# and Power Point Pin
wizardzz4-May-11 10:01
wizardzz4-May-11 10:01 
QuestionConnection String problem Pin
si_693-May-11 6:01
si_693-May-11 6:01 
AnswerRe: Connection String problem Pin
Ian Shlasko3-May-11 6:17
Ian Shlasko3-May-11 6:17 
AnswerRe: Connection String problem Pin
Pete O'Hanlon3-May-11 6:18
mvePete O'Hanlon3-May-11 6:18 
AnswerRe: Connection String problem Pin
DaveAuld3-May-11 6:20
professionalDaveAuld3-May-11 6:20 
AnswerRe: Connection String problem Pin
Luc Pattyn3-May-11 6:28
sitebuilderLuc Pattyn3-May-11 6:28 
GeneralRe: Connection String problem Pin
Pete O'Hanlon3-May-11 6:44
mvePete O'Hanlon3-May-11 6:44 
GeneralRe: Connection String problem Pin
Luc Pattyn3-May-11 6:51
sitebuilderLuc Pattyn3-May-11 6:51 
Questiona try inside another Pin
Ali Al Omairi(Abu AlHassan)3-May-11 0:44
professionalAli Al Omairi(Abu AlHassan)3-May-11 0:44 
AnswerRe: a try inside another Pin
Rick van Woudenberg3-May-11 1:07
Rick van Woudenberg3-May-11 1:07 
AnswerRe: a try inside another Pin
Luc Pattyn3-May-11 1:12
sitebuilderLuc Pattyn3-May-11 1:12 
GeneralRe: a try inside another Pin
Rick van Woudenberg3-May-11 1:21
Rick van Woudenberg3-May-11 1:21 
GeneralRe: a try inside another PinPopular
Pete O'Hanlon3-May-11 1:44
mvePete O'Hanlon3-May-11 1:44 
GeneralRe: a try inside another Pin
Rick van Woudenberg3-May-11 1:57
Rick van Woudenberg3-May-11 1:57 
GeneralRe: a try inside another Pin
J4amieC3-May-11 3:00
J4amieC3-May-11 3:00 
GeneralRe: a try inside another Pin
Rick van Woudenberg3-May-11 4:14
Rick van Woudenberg3-May-11 4:14 
Well, as far as I'm concerned both would be nice. Sure, the connection to the database has priority over user notification, however when something stuffs up, I generally let the user know. In that particular case I would do something like :

private void DoSomething()
{
  SqlConnection connection = null;
  try
  {
    connection = new SqlConnection();
    // Do something that might cause an exception...
    connection.Open();
  }
  catch(SqlException ex)  
  {
    MessageBox.Show(ex.ToString(); // or something else to notify the customer
  }
  finally
  {
    if (connection.ConnectionState == ConnectionState.Open)
      connection.Close();
  }
}


Then you actually have both of two worlds. However, that puts us right back to the essence of this discussion. Having a catch clause in a method is not something to be ashamed of, though I get the feeling that many developers think that way.
GeneralRe: a try inside another Pin
J4amieC3-May-11 4:36
J4amieC3-May-11 4:36 
GeneralRe: a try inside another Pin
BobJanova3-May-11 4:44
BobJanova3-May-11 4:44 
GeneralRe: a try inside another Pin
J4amieC3-May-11 4:50
J4amieC3-May-11 4:50 
GeneralRe: a try inside another Pin
Pete O'Hanlon3-May-11 5:41
mvePete O'Hanlon3-May-11 5:41 
GeneralRe: a try inside another Pin
Rick van Woudenberg3-May-11 23:52
Rick van Woudenberg3-May-11 23:52 
GeneralRe: a try inside another Pin
Gary Wheeler4-May-11 0:44
Gary Wheeler4-May-11 0:44 
GeneralRe: a try inside another Pin
DragonLord664-May-11 6:56
DragonLord664-May-11 6:56 
GeneralRe: a try inside another Pin
Pete O'Hanlon4-May-11 7:03
mvePete O'Hanlon4-May-11 7:03 

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.