Click here to Skip to main content
15,887,676 members
Home / Discussions / C#
   

C#

 
GeneralRe: Why Using during Sql Server Connection Pin
jschell14-Jul-12 6:55
jschell14-Jul-12 6:55 
GeneralRe: Why Using during Sql Server Connection Pin
munishk14-Jul-12 18:59
munishk14-Jul-12 18:59 
GeneralRe: Why Using during Sql Server Connection Pin
PIEBALDconsult15-Jul-12 7:30
mvePIEBALDconsult15-Jul-12 7:30 
GeneralRe: Why Using during Sql Server Connection Pin
jschell15-Jul-12 7:30
jschell15-Jul-12 7:30 
AnswerRe: Why Using during Sql Server Connection Pin
Wes Aday14-Jul-12 3:36
professionalWes Aday14-Jul-12 3:36 
AnswerRe: Why Using during Sql Server Connection PinPopular
OriginalGriff14-Jul-12 3:43
mveOriginalGriff14-Jul-12 3:43 
AnswerRe: Why Using during Sql Server Connection Pin
Luc Pattyn14-Jul-12 7:18
sitebuilderLuc Pattyn14-Jul-12 7:18 
AnswerRe: Why Using during Sql Server Connection Pin
PIEBALDconsult15-Jul-12 7:39
mvePIEBALDconsult15-Jul-12 7:39 
munishk wrote:
why it is recommended to use connection statements within using?


It isn't; I don't do it that way anyway. I dislike code that keeps instantiating and disposing Connections and Commands over and over again for no good reason. I prefer to instantiate each once and hold onto it for the duration -- opening and closing the Connection as needed, setting the CommandText, etc. But that's because of the type of systems I write; your systems may not benefit from it.

Additionally, I wrap Connections and Commands in my own classes which implement IDisposable, so when it makes sense to (mostly console utilities) I instantiate my class with a using statement:

using 
( 
    PIEBALD.Data.IDatabase db 
= 
    new PIEBLAD.Data.SqlServerDatabase 
    (
        ... 
    ) 
)
{
    ...
}

GeneralLooking for Volunteers Pin
Santa's Little Helper14-Jul-12 3:04
Santa's Little Helper14-Jul-12 3:04 
GeneralRe: Looking for Volunteers Pin
Eddy Vluggen14-Jul-12 3:37
professionalEddy Vluggen14-Jul-12 3:37 
GeneralRe: Looking for Volunteers Pin
Santa's Little Helper14-Jul-12 3:50
Santa's Little Helper14-Jul-12 3:50 
QuestionUI For C# Pin
atoi_powered13-Jul-12 10:23
atoi_powered13-Jul-12 10:23 
AnswerRe: UI For C# PinPopular
fjdiewornncalwe13-Jul-12 10:46
professionalfjdiewornncalwe13-Jul-12 10:46 
GeneralRe: UI For C# Pin
atoi_powered13-Jul-12 11:03
atoi_powered13-Jul-12 11:03 
AnswerRe: UI For C# Pin
Pete O'Hanlon13-Jul-12 12:20
mvePete O'Hanlon13-Jul-12 12:20 
GeneralRe: UI For C# Pin
atoi_powered13-Jul-12 12:56
atoi_powered13-Jul-12 12:56 
GeneralRe: UI For C# Pin
Mycroft Holmes13-Jul-12 13:37
professionalMycroft Holmes13-Jul-12 13:37 
GeneralRe: UI For C# Pin
Pete O'Hanlon13-Jul-12 22:11
mvePete O'Hanlon13-Jul-12 22:11 
QuestionC# - Isolated Storage Database Programming - Windows Phone Pin
ashish712-Jul-12 22:57
ashish712-Jul-12 22:57 
AnswerRe: C# - Isolated Storage Database Programming - Windows Phone Pin
Richard MacCutchan12-Jul-12 23:48
mveRichard MacCutchan12-Jul-12 23:48 
GeneralSp_attach_db Pin
pranee2412-Jul-12 6:34
pranee2412-Jul-12 6:34 
GeneralRe: Sp_attach_db Pin
Richard MacCutchan12-Jul-12 6:40
mveRichard MacCutchan12-Jul-12 6:40 
GeneralRe: Sp_attach_db Pin
Wes Aday12-Jul-12 6:47
professionalWes Aday12-Jul-12 6:47 
AnswerRe: Sp_attach_db Pin
Luc Pattyn12-Jul-12 11:59
sitebuilderLuc Pattyn12-Jul-12 11:59 
GeneralRe: Sp_attach_db Pin
KSaiPrasad12-Jul-12 19:30
KSaiPrasad12-Jul-12 19: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.