473,407 Members | 2,306 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

ExecuteReader error

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

Jul 10 '06 #1
1 4644
fniles,

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

Kerry Moorman
"fniles" wrote:
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

Jul 10 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: BuddyWork | last post by:
Does anyone know if there are any articles explaining how I could debug into SqlCommand.ExecuteReader so I can see why I am getting a particular error. thanks
0
by: BuddyWork | last post by:
Hello, The problem is that when using SqlCommand.ExecuteReader and the SQL statement raises an error of severity of 16 then ExecuteReader throws an exception, when you use...
6
by: karim | last post by:
I have an asp.net page that stopped running properly giving the error below. The app uses a SQL Server 2000 on another server. Enterprise Manager and Query analyzer on the web server can connect to...
2
by: MattB | last post by:
I'm trying to implement an example I found for displaying images stored in a SQL database. The example code looks like this (in page_load): Dim connstr As String = "Integrated...
1
by: shahi | last post by:
Hi all, i have a sp that produce an error when execute by some special parameters. i write a program in vb.net that execute it, but i come accross a strange problem: when i execute the sp...
7
by: Alec MacLean | last post by:
Hi all, I'm trying to deploy an ASP.NET (1.1) app to our production webserver, but having problems with the DAAB (from Ent Lib June 2005). As you might guess, it works just fine and dandy on my...
4
by: phil | last post by:
Hi, With the code below, i get the error: ExecuteReader: Connection property has not been initialized. Description: An unhandled exception occurred during the execution of the current web...
2
by: Martin Z | last post by:
I'm using the TableAdapterHelper to set the connection and transaction properties on all the commands of all my typed table adapters.... I've checked at the time of the error and all the commands...
7
by: fniles | last post by:
I am using VB.Net 2003 and MS Access (connecting using OleDBConnection). I read using DataAdapter and DataSet, not DataReader. When many people try to access the database at the same time, I get...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.