Solved

The OleDbCommand is currently busy Open, Fetching

Posted on 2006-07-18
9
762 Views
Last Modified: 2007-11-27
Hi,

When I perform a query, followed by another query, the OleDbCommand is still busy.  How should I re-initialize this?

Thanks,
Bob

sql = "SELECT * FROM DeliveryRunDetail WHERE ProcessName='Test';
dbCommand1.CommandText = sql;
dbCommand1.ExecuteNonQuery();
                        
reader = dbCommand1.ExecuteReader();      
while ( reader.Read() )
{
    // do something
}                        

sql = "DELETE * FROM DeliveryRunDetail WHERE ProcessName='Test2'";
dbCommand1.CommandText = sql;
dbCommand1.ExecuteNonQuery();
0
Comment
Question by:ba272
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 6

Expert Comment

by:mogun
ID: 17135006
Close Reader before executing other SQL commands using the same command object.

Cheers
Mohan
0
 
LVL 13

Assisted Solution

by:BlackTigerX
BlackTigerX earned 100 total points
ID: 17135320
reader.Close();                    
reader = dbCommand1.ExecuteReader();    
while ( reader.Read() )
{
    // do something
}        
0
 
LVL 6

Assisted Solution

by:mogun
mogun earned 100 total points
ID: 17138329
The correct one is

reader = dbCommand1.ExecuteReader();    
while ( reader.Read() )
{
    // do something
}                    

reader.Close();

sql = "DELETE * FROM DeliveryRunDetail WHERE ProcessName='Test2'";
dbCommand1.CommandText = sql;
dbCommand1.ExecuteNonQuery();
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 96

Expert Comment

by:Bob Learned
ID: 17141497
Creating a new command instance would be better.

Bob
0
 

Author Comment

by:ba272
ID: 17142814
Hey Bob,

could you give an example so we're on the same page?

Bob
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17142914
Bob,

Do you want to stick with the OleDbDataReader?

Bob
0
 

Author Comment

by:ba272
ID: 17143607
for now.  I've got quite a large program created.
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 300 total points
ID: 17151352
Try this, then:

sql = "DELETE * FROM DeliveryRunDetail WHERE ProcessName='Test2' ";
OleDbCommand dbCommand2 = new OleDbCommand(sql, connection);
dbCommand2.ExecuteNonQuery();

Bob
0
 

Author Comment

by:ba272
ID: 17151365
ok
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question