ExecuteReader error

F

fniles

I am using OLEDBDataReader to read from an Access database.

I have 4 data source where I get my data from, and each data source is in
its own thread.

When receiving data, if it is a new commodity I am need to read from the
database.

Since I can receive data from different data source at the same time, it is
possible that I read from the database at the same time.

During ExecuteReader sometimes I will get the error

"ExecuteReader requires an open and available Connection. The connection's
current state is Open, Executing."

How can I fix this ?



This are my codes:



Dim dr As OleDb.OleDbDataReader

Dim cmd As New OleDb.OleDbCommand



sql = "select [Open],[High],[Low],[Last] from CommodityPrice where Commodity
= '" & sContract & "'"

With cmd

.Connection = g_ConnectionOLE

.CommandText = sql

Try

dr = .ExecuteReader()

Catch ex As Exception

DBErr(bErr, bSuccess, ex, sCaller)

If bSuccess Then

cmd.Connection = g_ConnectionOLE

dr = cmd.ExecuteReader()

End If

End Try

End With
 
G

Guest

fniles,

Each thread needs to open its own connection, select its data from the
database, and then close the connection.

Kerry Moorman
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top