Solved

How to cancel Oracle query from VB.Net Windows Application

Posted on 2014-09-17
3
688 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
  • 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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Regarding swagger API 1 32
Excess Redo 3 31
VB.net Excel VSTO Add-in version compatability 2 13
vb.net datagrid point 4 17
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
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

713 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