I have an Oracle stored procedure that takes approx 3 minutes to execute and I am using .net 2.0 data access provider for oracle. Now i want to cancel the execution of stored procedure from .net after few seconds, the code i wrote for this is: -
-
//Start main function
-
-
System.Data.OracleClient.OracleDataAdapter objAdapter;
-
System.Data.OracleClient.OracleConnection con;
-
System.Threading.Timer objTimer = null;
-
-
if (!this.makeConnection(ref con, ref strExcpConn))
-
{
-
throw new ExceptionBRE(strExcpConn);
-
}
-
-
objTimer = new System.Threading.Timer(new System.Threading.TimerCallback(TimeClick),con, 5000, 5050);
-
objAdapter.Fill(objDataTable);
-
-
cmd.Connection.Close();
-
-
strB = BuildCommaSep(ref objDataTable);
-
return strB.ToString();
-
}
-
catch (Exception ex)
-
{
-
if (_iFlag == 1)
-
{
-
throw new Exception("Process kill by timer");
-
}
-
else
-
throw ex;
-
-
}
-
finally
-
{
-
objTimer.Dispose();
-
_iFlag = 0;
-
-
if (con != null && con.State != ConnectionState.Closed)
-
{
-
con.Close();
-
con.Dispose();
-
}
-
}
-
}
-
//End main function
-
-
-
//Timer callback function
-
//Closes and disposes OracleConnection object
-
//If command is still executing then OracleConnection.Close() will result in an exception
-
private void TimeClick(object state)
-
{
-
_iFlag = 1;
-
-
System.Data.OracleClient.OracleConnection objConn = (System.Data.OracleClient.OracleConnection)state;
-
if (objConn != null && objConn.State != ConnectionState.Closed)
-
{
-
objConn.Close();
-
objConn.Dispose();
-
}
-
}
-
Working of above code is that: Forcibly cancel running SQL Command if it doesn't reply in specified time by Closing the connection to database and throw custom exception message (using _iFlag variable).
Though it's throwing the correct exception but after the command executes completely. i.e. Timer is set to 5 secs to kill a procedure that takes ~3 mins but i get response that process kill by time after 3 mins, can any one tell me why?
Or is there any better of doing this?
Thanks in advance
4 3750 QVeen72 1,445
Recognized Expert Top Contributor
Hi,
Why dont you set the "CommandTimeOut " property...
Dim TCmd As New OleDbCommand
TCmd.CommandTim eout = 20 'In Seconds
Once execution starts, After waiting for 20 seconds, if there is no result, it is terminated and an error is Generated..
REgards
Veena
In my mind it may not be cancelling the request that is the problem here. If this was my application, I would spend time more redesigning/optimizing my stored procedures.
Hi,
Why dont you set the "CommandTimeOut " property...
Dim TCmd As New OleDbCommand
TCmd.CommandTim eout = 20 'In Seconds
Once execution starts, After waiting for 20 seconds, if there is no result, it is terminated and an error is Generated..
REgards
Veena
Data access provider for oracle from MS and ODP.NET 9.xxx doesn't support CommandTimeOut property.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Cath B |
last post by:
I am pretty sure I am getting a command timeout when execute a SQL
procedure that has an output parameter. The code below is in an asp
page that is called using RSGetASPObject. I want to be able to send a
message back to the calling page to indicate that a timeout has
occurred, but am having a hard time capturing the timeout error. I
intend to set the timeout parameters so that I don't get timeout
errors, but in the case that I would I...
|
by: rh0dium |
last post by:
Hi all,
Another newbie question. So you can't use signals on threads but you
can use select. The reason I want to do this in the first place it I
need a timeout. Fundamentally I want to run a command on another
machine, but I need a timeout. I have to do this to a LOT of machines
( > 3000 ) and threading becomes necessary for timeliess. So I created
a function which works with signals ( until you throw threading at it..
) but I...
|
by: Mike |
last post by:
VB .NET 2003, Pocket PC 2003, CF 1.0 SP 2
Only when I use a proxy server, I'm getting this error when attempting to
write data to a Stream object from an HTTPWebRequest object.
(System.IO.Stream.Write() raises the exception):"An existing connection was
forcibly closed by the remote host". The error only happens with fairly
large amounts of data (around 24,500 bytes).
Here is ToString() of the exception object raised:
|
by: twigster |
last post by:
Hi,
I need to display in real time the output of a command line tool in a
GUI written so far with Tkinter and Pmw. I've got a command line tool
that I want to integrate to a GUI. The parameters are set using the GUI
and a button executes the command. The calc is long so I need to see how
fast it goes. This is given by the stdout...
any idea how to do this?
|
by: Sanjay T |
last post by:
Hi,
We are using ASP.Net 2005 and SQL Server 2005. We are storing sessions in
the database. From time to time we get the following exception in the
application while the ASP.Net session tries accessing the database. This also
happens from time to time when our application is accessing the database. To
make the posting brief, I am just putting part of the exception.
Any ideas why this might be happening? Our web application is behind F5...
| |
by: Vicente García |
last post by:
Hello!! sorry for my english,
I've made an application that ran correctly for 3 days, It's a service, however in the third day the application failed because of "An existing connection was forcibly closed by the remote host" exception, and then the CPU usage was 95 %. I don't know why it happens :( The service is always runs and other application works with the service using sockets, the exception occur when the service tried to send a...
|
by: John Kotuby |
last post by:
Hi all,
I have set up a page with a Repeater and a SQLDatasource control, the data
control suggested by online Help for use with the Repeater. I am getting
Timeout Expired after 30 seconds. I expect many of my queries to take longer
than 30 seconds because they are ad hoc user-defined searches through
multiple joined tables and associated Text fields. I have to learn more
about creating full text indexes for searching...but.
How can I...
|
by: Gil_H |
last post by:
Hi,
I'm trying to run a script over unix on a remote machine.
In order to automate it, the procedure requests the following:
1. Using SSH connection.
2. Operating a command on the remote machine.
3. Expecting password or (yes/no) request and authorize it.
I get an error (I thing that it occures at the last part (3) of the
password request).
|
by: priravi |
last post by:
Hi,
I have a connection timeout of 400 and command timeout of 0 for a stored procedure . the stored procedure retrieves a long data and store it in dataset.
I'm getting the "System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding." exception thrown on that stored procedure ... any ideas why it may happen . i'm using execute dataset
|
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...
|
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,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |