Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ASP.NET asynchronous stored procedure

Posted on 2011-09-22
1
Medium Priority
?
383 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 23

Accepted Solution

by:
wdosanjos earned 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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 …
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

610 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