473,382 Members | 1,786 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Interrupt SQL Query

I'm using VS2005 Winforms. I want a method to allow the user to be able to
interrupt an SQL query if he decides he doesn't want to wait for it any
longer.

I've used IAsyncResult to open an async connection that runs an
ExecuteNonQuery, but this method doesn't allow interruption
(EndExecuteNonQuery gets blocked until the execute finishes), and ideally I'd
like to interrupt a Query rather than a NonQuery.

It seems to me this is a generic need that would be of value to many
developers.

Any ideas, article references, etc. would be greatly appreciated. If your
answer is SQL Server specific that would be fine, but my current project is
against Informix, so ideally I'd like the solution to be .Net generic.

Thanks in advance.
Apr 19 '07 #1
2 3249
Can't be done. Sending a query to a database is like a browser sending an
HTTP request to a web server. Once it's sent, you can't "unsend" it. The
database will continue to execute the task until it is complete. However,
like a browser, you can stop listening for a response and do something else.
Calling the database asynchronously will have the same effect, allowing your
app to forget about the response and continue working.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"Bruce HS" <Br*****@discussions.microsoft.comwrote in message
news:5C**********************************@microsof t.com...
I'm using VS2005 Winforms. I want a method to allow the user to be able
to
interrupt an SQL query if he decides he doesn't want to wait for it any
longer.

I've used IAsyncResult to open an async connection that runs an
ExecuteNonQuery, but this method doesn't allow interruption
(EndExecuteNonQuery gets blocked until the execute finishes), and ideally
I'd
like to interrupt a Query rather than a NonQuery.

It seems to me this is a generic need that would be of value to many
developers.

Any ideas, article references, etc. would be greatly appreciated. If your
answer is SQL Server specific that would be fine, but my current project
is
against Informix, so ideally I'd like the solution to be .Net generic.

Thanks in advance.


Apr 20 '07 #2
You may be right. However:

1) Queries issued from MSSQL Query Analyzer seem to be interruptable. Is
there perhaps a "call-back" capability that allows a client to tell the
server to stop a particular process?

2) If I follow your approach, do you have experience issuing an
EndExecuteNonQuery while an async command thread is still active?
Documentation says that it is "blocked" until the thread completes. Will
sending EndExecuteNonQuery early eventually "clean up" the thread so I don't
leave orphan threads?

3) Does anyone know of white papers or chapters in books that addresses this
fairly general need to interrupt Queries and stored procedures?

"Kevin Spencer" wrote:
Can't be done. Sending a query to a database is like a browser sending an
HTTP request to a web server. Once it's sent, you can't "unsend" it. The
database will continue to execute the task until it is complete. However,
like a browser, you can stop listening for a response and do something else.
Calling the database asynchronously will have the same effect, allowing your
app to forget about the response and continue working.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"Bruce HS" <Br*****@discussions.microsoft.comwrote in message
news:5C**********************************@microsof t.com...
I'm using VS2005 Winforms. I want a method to allow the user to be able
to
interrupt an SQL query if he decides he doesn't want to wait for it any
longer.

I've used IAsyncResult to open an async connection that runs an
ExecuteNonQuery, but this method doesn't allow interruption
(EndExecuteNonQuery gets blocked until the execute finishes), and ideally
I'd
like to interrupt a Query rather than a NonQuery.

It seems to me this is a generic need that would be of value to many
developers.

Any ideas, article references, etc. would be greatly appreciated. If your
answer is SQL Server specific that would be fine, but my current project
is
against Informix, so ideally I'd like the solution to be .Net generic.

Thanks in advance.


Apr 20 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Jane Austine | last post by:
As far as I know python's threading module models after Java's. However, I can't find something equivalent to Java's interrupt and isInterrupted methods, along with InterruptedException....
3
by: Russell Stuart via .NET 247 | last post by:
I always though .Net monitors were meant to be similar to thejava synchronisation mechanisms. The code below proves mewrong. When run under the debugger, it produces just "Thread 1"lines, as I...
2
by: Marco | last post by:
Hallo, I have made a microcontroller with keyboard (16 key). I have a function to handle interrupt that comes from keyboard when a key is pressed. I should make a C software (not graphic) with...
2
by: anil | last post by:
Hi Friends!! Does any body know the interrupt no. of the CD-Rom device to make it function like opening and reading etc..If any body knoow tell me ..I want to learn hardware programming through...
0
by: LordHog | last post by:
Hello all, I have a little application that will be used for test environment that utilizes the CAN Messaging. The application will capture and then decode the CAN message that are received. In...
2
by: bvermeersch | last post by:
Hi, Here I am again, just learning C# and always wanting to learn the hard things first. As you might already know from other posts I'm trying to convert c++ code to C#. The problem I'm...
27
by: tomhr | last post by:
I have a Borland Turbo C++ compiler (though I never use the "plus-plus" part), copyright 1990. I use this compiler to write simple programs, one of which I am quite dependent on. A month ago, my...
2
by: Hartmut | last post by:
Hi guys out there..., I am not shure if this is the right forum for my Question. Have a problem using my own Keyboard interrupt handler. The handler works fine as long as i do not press keys...
5
by: mysli | last post by:
Hi all, I need to write a ISR using Microsoft VC++ 2005. The proplem is I did not found any hint on how to do it. I can register any function as a ISR and it will be called by the hardware...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.