?
Solved

The OleDbCommand is currently busy Open, Fetching

Posted on 2006-07-18
9
Medium Priority
?
763 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 400 total points
ID: 17135320
reader.Close();                    
reader = dbCommand1.ExecuteReader();    
while ( reader.Read() )
{
    // do something
}        
0
 
LVL 6

Assisted Solution

by:mogun
mogun earned 400 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 1200 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

777 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