Solved

ASP.NET asynchronous stored procedure

Posted on 2011-09-22
1
375 Views
Last Modified: 2012-05-12
I have a method that calls a long running sp from an ASP.NET page.  What I want to be able to do is start executing the sp, and continue with any other statments that may need to be executed in the page.  I also require the sp to continue running even after the web app closes.  I don't need any results returned to the web page as I'm writing to a table in the database on completion.

What would be the best way to handle this.

Including the code that calls the sp.

thanks
Dim retValue As Integer = 0

            Using connection As New SqlClient.SqlConnection(connectString)
                Dim command As SqlClient.SqlCommand = connection.CreateCommand

                command.CommandType = CommandType.StoredProcedure
                command.CommandText = "LongProcess"
                command.CommandTimeout = 18000 ' 5 hours

                command.Parameters.Add("@Descrip", SqlDbType.VarChar).Value = descrip

                Try
                    command.Connection.Open()
                    retValue = command.ExecuteNonQuery

                Catch ex As Exception
                    Throw ex
                End Try
            End Using
            Return retValue
        End Function

Open in new window

0
Comment
Question by:dthansen
1 Comment
 
LVL 23

Accepted Solution

by:
wdosanjos earned 500 total points
ID: 36582026
Please check the following discussion.  It recommends the use of ThreadPool.QueueUseWorkItem.

BeginExecuteNonQuery without EndExecuteNonQuery
http://stackoverflow.com/questions/1544905/beginexecutenonquery-without-endexecutenonquery
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASCX file or a newer alternative? 1 34
mail.To.Add 5 25
SQL Server 2012 r2 - Sum totals 2 23
domain login has permission in database, but gets error 3 10
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

785 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