Solved

ASP.NET asynchronous stored procedure

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

863 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

24 Experts available now in Live!

Get 1:1 Help Now