Click here to Skip to main content
15,891,833 members
Home / Discussions / C#
   

C#

 
AnswerRe: Is the "using" statement really a good idea? Pin
Richard Deeming30-Jul-19 7:42
mveRichard Deeming30-Jul-19 7:42 
GeneralRe: Is the "using" statement really a good idea? Pin
MSBassSinger30-Jul-19 8:05
professionalMSBassSinger30-Jul-19 8:05 
GeneralRe: Is the "using" statement really a good idea? Pin
Richard Deeming30-Jul-19 8:15
mveRichard Deeming30-Jul-19 8:15 
GeneralRe: Is the "using" statement really a good idea? Pin
MSBassSinger30-Jul-19 8:26
professionalMSBassSinger30-Jul-19 8:26 
AnswerRe: Is the "using" statement really a good idea? Pin
Dave Kreskowiak30-Jul-19 8:03
mveDave Kreskowiak30-Jul-19 8:03 
GeneralRe: Is the "using" statement really a good idea? Pin
MSBassSinger30-Jul-19 8:07
professionalMSBassSinger30-Jul-19 8:07 
GeneralRe: Is the "using" statement really a good idea? Pin
Dave Kreskowiak30-Jul-19 8:21
mveDave Kreskowiak30-Jul-19 8:21 
GeneralRe: Is the "using" statement really a good idea? Pin
MSBassSinger30-Jul-19 8:47
professionalMSBassSinger30-Jul-19 8:47 
Quote:
I'm going to concerned with just two things. Any exceptions thrown by the Command and the data returned.


I understand and agree with what you say. But, I look for more. When something does go wrong in production, I'd like the debug log to have captured the runtime values of what I was using in the SqlConnection and SqlCommand object. With those, I can quickly tell if there was something wrong with the values (e.g. did someone diddle with a config file that had connection info?). Or maybe some of my query parameter values were unexpected. In any case, by having captured them in a catch block, I spend 5 minutes on solving a problem, instead of an hour or more guessing at what might have caused it. I could embed a try-catch within the using statement (not sure if the instantiation portion of the using statement would get "caught" in the catch block, though), but then if I have the try-catch, why not just add finally and do away with the redundancy of the using statement?

If the values seem OK, with the try-catch-finally, I can step through all the code, which is limited with the using statement.

I understand if these things are not valuable to you. But they are to me after many years of running into the odd issues that could have been solved by a couple more lines of code. Every developer has to pick and chose what they consider valuable to them, as well as to a customer.
GeneralRe: Is the "using" statement really a good idea? Pin
Dave Kreskowiak30-Jul-19 13:16
mveDave Kreskowiak30-Jul-19 13:16 
AnswerRe: Is the "using" statement really a good idea? Pin
OriginalGriff30-Jul-19 8:06
mveOriginalGriff30-Jul-19 8:06 
GeneralRe: Is the "using" statement really a good idea? Pin
MSBassSinger30-Jul-19 8:19
professionalMSBassSinger30-Jul-19 8:19 
GeneralRe: Is the "using" statement really a good idea? Pin
OriginalGriff30-Jul-19 9:44
mveOriginalGriff30-Jul-19 9:44 
GeneralRe: Is the "using" statement really a good idea? Pin
MSBassSinger30-Jul-19 9:50
professionalMSBassSinger30-Jul-19 9:50 
GeneralRe: Is the "using" statement really a good idea? Pin
Dave Kreskowiak30-Jul-19 13:19
mveDave Kreskowiak30-Jul-19 13:19 
AnswerRe: Is the "using" statement really a good idea? Pin
MSBassSinger30-Jul-19 10:09
professionalMSBassSinger30-Jul-19 10:09 
AnswerRe: Is the "using" statement really a good idea? Pin
Gerry Schmitz31-Jul-19 4:32
mveGerry Schmitz31-Jul-19 4:32 
Questioncapture the screenshot of desktop using C# Pin
Member 1454529529-Jul-19 22:41
Member 1454529529-Jul-19 22:41 
AnswerRe: capture the screenshot of desktop using C# Pin
OriginalGriff29-Jul-19 23:26
mveOriginalGriff29-Jul-19 23:26 
AnswerRe: capture the screenshot of desktop using C# Pin
Afzaal Ahmad Zeeshan30-Jul-19 5:29
professionalAfzaal Ahmad Zeeshan30-Jul-19 5:29 
QuestionCreating a struct dynamically Pin
Member 1452625729-Jul-19 21:48
Member 1452625729-Jul-19 21:48 
AnswerRe: Creating a struct dynamically Pin
OriginalGriff29-Jul-19 22:06
mveOriginalGriff29-Jul-19 22:06 
AnswerRe: Creating a struct dynamically Pin
BillWoodruff31-Jul-19 14:28
professionalBillWoodruff31-Jul-19 14:28 
SuggestionRe: Creating a struct dynamically Pin
Richard Deeming1-Aug-19 1:40
mveRichard Deeming1-Aug-19 1:40 
GeneralRe: Creating a struct dynamically Pin
BillWoodruff1-Aug-19 8:47
professionalBillWoodruff1-Aug-19 8:47 
QuestionError when i try to add my control to form1 Pin
_Q12_29-Jul-19 8:30
_Q12_29-Jul-19 8:30 

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.