Solved

ASP.NET asynchronous stored procedure

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

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 …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

733 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