Blain,

I believe that the DataReader does not automatically close like a DataAdapter
does.



> -----Original Message-----
> From: The DOTNET list will be retired 7/1/02
> [mailto:[EMAIL PROTECTED]]On Behalf Of Blain Timberlake
> Sent: Wednesday, June 05, 2002 7:46 AM
> To: [EMAIL PROTECTED]
> Subject: [DOTNET] Connection Question
>
>
> I hate to ask this before the DotNet-Morons list is up and working, but
> I'm sort of confused about this.
>
> I have a project that has one connection, and 3 data adapters and 4 or 5
> command objects.
>
> The project has 2 timers.
>
> tmrRequests fires every 10 seconds
> tmrMonitor fires ever 10 minutes
>
>
> Everything works fine at first but then eventually I start getting
> errors in the eventlog that are: "There is already an open DataReader
> associated with this Connection which must be closed first."
>
> So something must be going wonky after a little while, and those errors,
> once they start just continue every 10 seconds.
>
> So when I'm working with the connection I do the following:
>         Try
>             Dim dsRunningParams As DataSet = New DataSet()
>             Dim table As DataTable
>             Dim row As DataRow
>             Dim rowIndex As Integer
>
>             If conReportDB.State = ConnectionState.Closed Then
>                         conReportDB.Open()
>             daGetRunningParams.Fill(dsRunningParams)
>             conReportDB.Close()
>
>                 .... work with data here...
>
>         Catch e as exception
>                 If conReportDB.State = ConnectionState.Open Then
> conReportDB.Close()
>
>         Finally
>                 If conReportDB.State = ConnectionState.Open Then
> conReportDB.Close()
>
>         End try
>
>
> I thought that was sufficient to take care of everything, but apparently
> something eventually stays attached somewhere and I'm not sure where.
> All the code I have using the connection follows the same format as
> shown above.  Is there something I'm not doing to release things
> properly?
>
> Also... would this be happening randomly b/c the 10 minute timer
> eventually collides with the 10second timer and they're both trying to
> use the same connection?  Is there a good way to avoid that or should I
> establish another connection for that timer to use?
>
> Again, sorry for the dumb question.
>
> =Blain
>
> You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
> subscribe to other DevelopMentor lists at http://discuss.develop.com.
>

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to