Click here to Skip to main content
15,926,858 members
Home / Discussions / C#
   

C#

 
GeneralRe: \\computer\shared Pin
Richard Deeming18-Jun-04 7:24
mveRichard Deeming18-Jun-04 7:24 
GeneralRe: \\computer\shared Pin
lustuyck20-Jun-04 22:05
lustuyck20-Jun-04 22:05 
QuestionHow to brows Datasets on other form in my component that droped on a form. Pin
Member 114126618-Jun-04 4:05
Member 114126618-Jun-04 4:05 
AnswerRe: How to brows Datasets on other form in my component that droped on a form. Pin
Heath Stewart18-Jun-04 4:10
protectorHeath Stewart18-Jun-04 4:10 
GeneralRe: How to brows Datasets on other form in my component that droped on a form. Pin
Member 114126618-Jun-04 4:51
Member 114126618-Jun-04 4:51 
GeneralClosing a OleDbConnection Pin
PaleyX18-Jun-04 3:50
PaleyX18-Jun-04 3:50 
GeneralRe: Closing a OleDbConnection Pin
Dave Kreskowiak18-Jun-04 4:05
mveDave Kreskowiak18-Jun-04 4:05 
GeneralRe: Closing a OleDbConnection Pin
Heath Stewart18-Jun-04 4:06
protectorHeath Stewart18-Jun-04 4:06 
Instead of knocking .NET, you should try reading about it before making snap decisions. For example, setting the variable to null after calling Dispose is entirely unncessary.

Also - being a C++ developer - you should know better than to assume a flagged enumeration may have only one enum value set. Instead of _dbConnection.State == ConnectionState.Open, you should use (_dbConnection.State & ConnectionState.Open) != 0) or something similar.

If you're multi-threading this code, it's possible that a command may be executing using that connection, which other ConnectionState values can tell you.

When you're done, all you need to do is call _dbConnection.Dispose(), which will close the connection and free unmanaged resources. Doing all three of those is unncessary. Why is there a Close in addition to Dispose? Because you may want to re-open the connection later, but if you dispose it, you can't - you'll get an ObjectDisposedException, since it has already been disposed.

If you read and understand the documentation for the .NET Framework, this can be a very good environment, but if you prefer VC++ that's fine, too. Just don't knock something because you did something wrong.

 

Microsoft MVP, Visual C#
My Articles
GeneralRe: Closing a OleDbConnection Pin
PaleyX19-Jun-04 4:54
PaleyX19-Jun-04 4:54 
GeneralOutlook question... Pin
Tartampion18-Jun-04 3:13
Tartampion18-Jun-04 3:13 
GeneralRe: Outlook question... Pin
Stefan Troschuetz18-Jun-04 3:25
Stefan Troschuetz18-Jun-04 3:25 
GeneralRe: Outlook question... Pin
Dave Kreskowiak18-Jun-04 4:00
mveDave Kreskowiak18-Jun-04 4:00 
GeneralRe: Outlook question... Pin
Tartampion18-Jun-04 4:16
Tartampion18-Jun-04 4:16 
GeneralCan't capture arrow keys Pin
jjansen18-Jun-04 3:01
jjansen18-Jun-04 3:01 
GeneralRe: Can't capture arrow keys Pin
Judah Gabriel Himango18-Jun-04 4:42
sponsorJudah Gabriel Himango18-Jun-04 4:42 
GeneralRe: Can't capture arrow keys Pin
Werdna18-Jun-04 10:34
Werdna18-Jun-04 10:34 
GeneralReading Excel Data in C# Pin
Member 445055118-Jun-04 2:06
Member 445055118-Jun-04 2:06 
GeneralRe: Reading Excel Data in C# Pin
Dave Kreskowiak18-Jun-04 3:58
mveDave Kreskowiak18-Jun-04 3:58 
GeneralRe: Reading Excel Data in C# Pin
Heath Stewart18-Jun-04 4:01
protectorHeath Stewart18-Jun-04 4:01 
GeneralOwn Error Message Pin
visitsaadi18-Jun-04 1:41
visitsaadi18-Jun-04 1:41 
GeneralRe: Own Error Message Pin
Stefan Troschuetz18-Jun-04 1:53
Stefan Troschuetz18-Jun-04 1:53 
GeneralRe: Own Error Message Pin
Dave Kreskowiak18-Jun-04 3:49
mveDave Kreskowiak18-Jun-04 3:49 
Questionwhere are you Michael W. McKechney? Pin
DawnYoshimura18-Jun-04 1:11
DawnYoshimura18-Jun-04 1:11 
AnswerRe: where are you Michael W. McKechney? Pin
Michael P Butler18-Jun-04 5:00
Michael P Butler18-Jun-04 5:00 
GeneralCreating Typesafe Collections Pin
matthias s.18-Jun-04 0:53
matthias s.18-Jun-04 0:53 

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.