Solved

difference between executeCommand() and executeReader()

Posted on 2007-12-04
2
375 Views
Last Modified: 2008-02-01
Hi experts,

I have a select statement that I want to commit to the database. Parallely I created a manual lock on the dataset which I used in my select statement. To commit the select statement I used the method executeReader() first. Since that method throws an SQLException I expected it to throw it - but it didn't. After I couldn't figure out why it doesn't throw the exception, I tried using the executeCommand() method. That worked. It threw the SQLException as expected. But when I tried to use a select statement on another dataset in that table, it also threw the exception.
My questions:
1) Why doesn't the executeReader() method throw an exception when the executeCommand() method does?
2) To me it seems that executeCommand() puts a lock on the whole table whereas executeReader() only locks the specific dataset. Is that correct?
3) Can someone give some advice to the optimal solution for my problem?

Thanks a lot!
0
Comment
Question by:arthrex
2 Comments
 
LVL 42

Accepted Solution

by:
dqmq earned 500 total points
ID: 20404646
1.  Both ExecuteReader and ExecuteCommand use the same command/connection objects under the covers. So, I do not understand why one would fail and the other not.  The only thing that comes to mind is that the executeReader is not set up properly and is raising a higher level exception.

2.  No.  

3. What's the exception?
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

920 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now