OracleDataReader.Close() needed to release Open Cursors
382478Dec 4 2003 — edited Aug 1 2007I noticed that if I follow the idiom for using OracleDataReader as given in the examples that accompany ODP, it is not good enough for cleaning up.
For example, all the examples provided use something like this:
--------------
try
{
con.Open();
rdr = cmd.ExecuteReader();
...do stuff with rdr
}
finally
{
cmd.Dispose();
con.Close();
con.Dispose();
}
-----------
But that's not good enough. If I do this 20 times, I get 20 identical open cursors.
If, however, the finally block is coded like this,
-----------
finally
{
rdr.Close();
rdr.Dispose();
cmd.Dispose();
con.Close();
con.Dispose();
}
--------------
Then there are NO open cursors after this is all over with.
For Oracle people: Is this the intended behavior?
For everyone else: Where you aware you needed to do this to clean up?
I didn't know to do this since none of the examples do this.
If it turns out this is best practice for ODP, I recommend the examples be updated to do this.
If I'm misunderstanding something, then someone please educate me.
Thanks,
David Kreth Allen
Carlson School of Management
University of Minnesota