473,800 Members | 2,893 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
(EndExecuteNonQ uery 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 3278
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*****@discus sions.microsoft .comwrote in message
news:5C******** *************** ***********@mic rosoft.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
(EndExecuteNonQ uery 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
EndExecuteNonQu ery while an async command thread is still active?
Documentation says that it is "blocked" until the thread completes. Will
sending EndExecuteNonQu ery 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*****@discus sions.microsoft .comwrote in message
news:5C******** *************** ***********@mic rosoft.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
(EndExecuteNonQ uery 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
6494
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. "somethread.interrupt()" will wake somethread up when it's in sleeping/waiting state. Is there any way of doing this with python's thread? I suppose thread interrupt is a very primitive functionality for stopping a blocked thread.
3
1671
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 expected. But when run without the debugger itproduced both "Thread 1" and "Thread 2" lines, impling that twothreads are executing in the same lock region. I though thatwasn't supposed to happen. Am I wrong? using System; using System.Threading;...
2
2451
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 a menu. I thought to make into main.c a cicle like this: while (1)
2
1913
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 C.. awaiting reply ----anil
0
1766
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 the API reference material the device will generate an interrupt which the user much provide an interrupt service routine with the entry pointed at the interrupt 0x16 vector ( Address = 0x0083 ). Is it possible to write an interrupt service...
2
7072
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 running into now is the creation and handling of an interrupt. In c++ it is done this way:
27
2825
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 parallel-port-output printer died, and I got a Samsung printer that takes info from the USB port. Every time I go into DOS mode and try to send something to that printer, whether from a command line ("dir>prn"), or from one of my programs, I get...
2
4097
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 like pause, arrow keys etc. My system returns with a stack overflow. Is there something i have overseen in my keyboard Interrupt Service
5
4264
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 interrupt, interrupt 8 (timer) i.e., works fine in my little example progam. But the problem is the compiler ends every function with RETN, after disassembling the result of the compilation this can be seen easiely. Every function starts and ends with:
0
9690
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9550
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10273
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10250
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10032
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5603
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.