Click here to Skip to main content
15,881,803 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to Get Data From Data Set Pin
Orcun Iyigun10-Mar-11 5:50
Orcun Iyigun10-Mar-11 5:50 
GeneralRe: How to Get Data From Data Set Pin
OriginalGriff10-Mar-11 8:21
mveOriginalGriff10-Mar-11 8:21 
AnswerRe: How to Get Data From Data Set Pin
GauravKP10-Mar-11 0:54
professionalGauravKP10-Mar-11 0:54 
GeneralRe: How to Get Data From Data Set Pin
Anubhava Dimri10-Mar-11 1:02
Anubhava Dimri10-Mar-11 1:02 
QuestionDISPOSE OR CLOSE Pin
Anubhava Dimri9-Mar-11 18:46
Anubhava Dimri9-Mar-11 18:46 
AnswerRe: DISPOSE OR CLOSE Pin
Saksida Bojan9-Mar-11 20:25
Saksida Bojan9-Mar-11 20:25 
AnswerRe: DISPOSE OR CLOSE Pin
OriginalGriff9-Mar-11 21:21
mveOriginalGriff9-Mar-11 21:21 
GeneralRe: DISPOSE OR CLOSE Pin
Łukasz Nowakowski10-Mar-11 4:20
Łukasz Nowakowski10-Mar-11 4:20 
Theoretically, you're right. But in my company we had some troubles, when we used construct you're suggesting. The problem was, that connection wasn't always closed, when enclosed in using. So we are using construction as below:
using (SqlCommand command = new SqlCommand())
{
    // Set command properties as needed
    using (command.Connection = new SqlConnection(connectionString))
    {
        try
        {
            command.Connection.Open();
            // Execute command, retrieve data from result, or whatever you want to do with the command
        }
        catch(Exception)
        {
            // Handling exceptions: logging, rethrowing, whatever
        }
        finally
        {
            command.Connection.Close();
        }
    }
}

And concerning the question... link[^]
It says, that "Close and Dispose are functionally equivalent". Therefore I think you should use Close rather, than Dispose. It makes code easier to read, because you can see the pair of methods: Open - Close, and you know, that they're connected to each other.
Don't forget to rate answer, that helped you. It will allow other people find their answers faster.

AnswerRe: DISPOSE OR CLOSE Pin
PIEBALDconsult10-Mar-11 1:52
mvePIEBALDconsult10-Mar-11 1:52 
GeneralRe: DISPOSE OR CLOSE Pin
Anubhava Dimri10-Mar-11 1:54
Anubhava Dimri10-Mar-11 1:54 
AnswerRe: DISPOSE OR CLOSE Pin
jschell10-Mar-11 8:54
jschell10-Mar-11 8:54 
GeneralRe: DISPOSE OR CLOSE Pin
PIEBALDconsult10-Mar-11 13:23
mvePIEBALDconsult10-Mar-11 13:23 
GeneralRe: DISPOSE OR CLOSE Pin
jschell11-Mar-11 9:05
jschell11-Mar-11 9:05 
Questionhow to develop mobile application in c#? [modified] Pin
sairam.bhat9-Mar-11 18:44
sairam.bhat9-Mar-11 18:44 
AnswerRe: who was here? Pin
Anubhava Dimri9-Mar-11 18:49
Anubhava Dimri9-Mar-11 18:49 
AnswerRe: who was here? Pin
RobCroll9-Mar-11 18:52
RobCroll9-Mar-11 18:52 
AnswerRe: how to develop mobile application in c#? Pin
Richard MacCutchan9-Mar-11 22:14
mveRichard MacCutchan9-Mar-11 22:14 
AnswerRe: how to develop mobile application in c#? Pin
_Erik_10-Mar-11 0:58
_Erik_10-Mar-11 0:58 
QuestionCalling a function stored in an SQL data field along with text Pin
Nick Listerman9-Mar-11 16:49
Nick Listerman9-Mar-11 16:49 
AnswerRe: Calling a function stored in an SQL data field along with text Pin
PIEBALDconsult10-Mar-11 1:55
mvePIEBALDconsult10-Mar-11 1:55 
QuestionAccessing DataSet getting error Pin
MAW309-Mar-11 14:57
MAW309-Mar-11 14:57 
Question[Outlook] is It possible to get sender's email address from AppointmentItem? Pin
buffering839-Mar-11 14:53
buffering839-Mar-11 14:53 
AnswerRe: [Outlook] is It possible to get sender's email address from AppointmentItem? Pin
sohail72018-Jul-11 3:29
sohail72018-Jul-11 3:29 
QuestionRandom number generation between a given interval Pin
prakulsol9-Mar-11 6:11
prakulsol9-Mar-11 6:11 
AnswerRe: Random number generation between a given interval Pin
Luc Pattyn9-Mar-11 6:19
sitebuilderLuc Pattyn9-Mar-11 6:19 

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.