Solved

How to cancel Oracle query from VB.Net Windows Application

Posted on 2014-09-17
3
750 Views
Last Modified: 2014-09-29
I have a straightforward windows application written using VB.Net, Visual Studio 2010 using the Oracle Data Provider.

Sometimes Users issue queries that take a long time to process and would like to cancel the query.

I would like to display a button above a Datagrid that says "Cancel" and when clicked, abort the query and kill the User request with Oracle.  TOAD currently uses this functionality but I don't know how they do it.

Any code snippets would be greatly appreciated.
0
Comment
Question by:BISCO3
[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
  • 2
3 Comments
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 40328438
If you are using ODP.Net try:

OracleCommand.Cancel

http://docs.oracle.com/cd/B19306_01/win.102/b14307/OracleCommandClass.htm#DAFIEHHG

There is an example in that doc link.

If you aren't using ODP.Net, I would STRONGLY encourage you to start.
0
 

Author Comment

by:BISCO3
ID: 40331433
That's good for a scalar command but what about cancelling a Fill operation on a Data Adapter?
0
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 40331640
I'm not a .Net guy.  I'm an Oracle DBA that knows enough .Net to be more than a little dangerous.

I think you have officially exceeded my .Net abilities!

That said:
1:  I found the link below that is likely a SQL Server solution but the commands should port to ODP.Net pretty easily:
http://social.msdn.microsoft.com/Forums/vstudio/en-US/ad4f5811-a08d-4342-bcf1-368ceac834fc/is-there-any-way-to-cancel-a-dataadapterfill-command-while-its-processing?forum=csharpgeneral

2:  A DBA tends to provide database centric solutions.  I beleive you can limit the execution time with resource management but I've never played with any of this:
http://docs.oracle.com/cd/E11882_01/server.112/e25494/dbrm.htm#ADMIN11857

3: Tag the select that is used in the fill with a unique 'comment':
select /* UNIQUE_COMMENT_1234567890 */ sysdate from dual;

Then on the app side, find the sid and serial# (for example, 1 and 123) of that exact select statement and execute the following SQL:
alter system kill session '1,123';
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
Suggested Courses

627 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