we have a try, catch, finally around our derived class
code that gets the datareader from the base class.
In the finally, we close the reader, close the connection
and set the connection=nothing.
Any other ideas?
>-----Original Message-----
>If you are inheriting, make sure you close() and/or
dispose() on the base
>class from the derived class.
>
>
>---
>
>Gregory A. Beamer
>MVP; MCP: +I, SE, SD, DBA
>
>***************************
>Think Outside the Box!
>***************************
>
>
>"mark" wrote:
>
>> We are seeing a ton of this error:
>> There is already an open DataReader associated with
this
>> Connection which must be closed first.
>>
>>
>> I've went through all code that uses a datareader and
made
>> sure that we are calling the .close() method on the
>> readers once we're finished.
>> We use a custom framework for our data access, where we
>> inherit from a class which contains this code. In that
>> base class, it keeps a member variable for the
connection
>> object, so it can be reused. Does anyone know of an
issue
>> with doing this? That's all I can think of.
>> Here's our method that gets our connection object which
is
>> used by our getreader method in our base class.
>>
>> Protected Overrides Function getConnection() As
>> IDbConnection
>> If mobjConnection Is Nothing Then
>> mobjConnection = New SqlConnection
>> (ConnectionString)
>> mobjConnection.Open()
>> Else
>> If mobjConnection.State <>
>> ConnectionState.Open Then
>> Try
>> mobjConnection.Open()
>> Catch ex As Exception
>> End Try
>> End If
>> End If
>> Return mobjConnection
>> End Function
>>
>.
>
|