G
Guest
Hi all,
I have a minor problem,
The MSDN documentation say that a DataReader must always be explicitly
closed in your code.
Now .. If I assign a DataReader in a try block (as one really should) and
then assume that an exception could be thrown by some other code in that try
block, it seems reasonable to me that I should close the DataReader int the
catch block, as well as the try block.
If I do this the compiler complains about using an unassigned local variable
int the catch block .. tut!
So .. I put the close command in the finally block .. same compiler error ..
hmmm.
The question is .. Do I really have to assign the DataReader in a try-catch
all it's own to ensure that I can subsequently close it, even if another
exception is thrown elsewhere?
Any enlightenment very much appreciated.
MFK.
I have a minor problem,
The MSDN documentation say that a DataReader must always be explicitly
closed in your code.
Now .. If I assign a DataReader in a try block (as one really should) and
then assume that an exception could be thrown by some other code in that try
block, it seems reasonable to me that I should close the DataReader int the
catch block, as well as the try block.
If I do this the compiler complains about using an unassigned local variable
int the catch block .. tut!
So .. I put the close command in the finally block .. same compiler error ..
hmmm.
The question is .. Do I really have to assign the DataReader in a try-catch
all it's own to ensure that I can subsequently close it, even if another
exception is thrown elsewhere?
Any enlightenment very much appreciated.
MFK.