BeginExecuteNonQuery(); does not finish stored procedure

T

tequila00shots

Hello,

I have code that calls a long running stored procedure from a web page
button. After the first exec statement is called and finishes (about
45 minutes) the other exec statements do not run. I do not care what
happens to the web page after the user clicks the button, but I need
the stored procedure to finish. Is there any way I can make it
happen?

Below is the code:
protected void Button1_Click(object sender, EventArgs e)
{

try
{

SqlConnection cnVmwareBackup = new SqlConnection
("server=localhost;integrated
security=true;database=vmwareBackup;async=true");
SqlCommand cmdCopy = new SqlCommand("dbo.copyCA",
cnVmwareBackup);
cmdCopy.CommandTimeout = 4200;
cmdCopy.CommandType =
CommandType.StoredProcedure;
Session.Timeout = 4200;
Server.ScriptTimeout = 4200;
//cnVmwareBackup.ConnectionTimeout = 4200;

cnVmwareBackup.Open();
cmdCopy.BeginExecuteNonQuery();
Button1.Text = "You may close the web page";
//cmdCopy.EndExecuteNonQuery();
//cmdCopy.ExecuteNonQuery();
//cnVmwareBackup.Close();
}
catch
{
Button1.Text = "Failed - Please check the server
logs.";
}
 
T

tequila00shots

The page has timed-out ( within a few minutes or seconds)  off the Web
server, and it's not coming back to run anything thing else. You shouldn't
have an ASP.NET Web page  solution connecting to SQL Server for more than a
few seconds. The Web page connects to SQL server, SQL server does what it
has to do, things are done, and it comes back with in a few seconds -- NOT
45 minutes. :)

Just what is it you're trying to do that needs 45 minutes to run? At best,
you have a Windows service that running in the background that the Web page
contacts, and let the Windows Service do this process of 45 minutes or
whatever else is needed, since you don't care what the Web page does after
that.

Thanks...I will give it a try.

The stored procedure runs a ssis package that copies a large file from
one server to another.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top