Solved

ASP.NET asynchronous stored procedure

Posted on 2011-09-22
1
373 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now