Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6812689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:28:46+00:00 2026-05-26T20:28:46+00:00

Aim: Calling a very slow stored procedure (with parameters) asynchronously from code behind of

  • 0

Aim: Calling a very slow stored procedure (with parameters) asynchronously from code behind of an asp.net web page via single function call, and then forgetting about it.

Notes: I tried using SqlCommand.BeginExecuteNonQuery without calling SqlCommand.EndExecuteNonQuery (see the code below), but the stored procedure didn’t run. (I used a tiny stored procedure to update single field on a table for testing but the field was not updated. It gets update when I use SqlCommand.ExecuteNonQuery).

I am not interested in and don’t know when the stored procedure will end. (So I can’t wait for it to finish to call SqlCommand.EndExecuteNonQuery.)

Situation:
After some research, I found out that sql jobs can be used for this purpose. And for the sp parameters; I can store them in a table and then sp can read them. However I don’t know if this is the right approach to my problem (I am new to SQL world). I hope you can comment on usage of an sql job for this purpose, or suggest alternatives. Thanks.

Code:

    using (SqlConnection connection = new SqlConnection(
        @"Data Source=XXX\MSSQL2008R2;Initial Catalog=YYY;Integrated Security=True"
        + ";Asynchronous Processing=true"))
    {
        connection.Open();
        SqlCommand cmd = new SqlCommand("spTestProcedure", connection);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add(new SqlParameter("@pText", DateTime.Now.ToString()));
        cmd.BeginExecuteNonQuery(); //Doesn't work.
        //cmd.ExecuteNonQuery(); // This works.
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:28:47+00:00Added an answer on May 26, 2026 at 8:28 pm

    I was looking for a way of doing this from the code behind of asp.net, but realized there is no easy way of doing it (I didn’t want to think about connection or time out problems). I ended up doing it via a web service.

    1. From asp.net code behind, I call my webs service’s function synchronously.
    2. Within the web service’s function, I call the stored procedure asynchronously using SqlCommand.BeginexecuteNonQuery(AsyncCallback, Object).
    3. The callback is handled within the web service (for error handling).

    Hence my web page keeps working the way I want: Fire the request once, then forget about it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

my aim is to invoke a shell script from a PHP program and then
The aim is to be able to switch debugging calls on at run-time from
I am calling a python script from PHP. The python program has to return
My ultimate aim is to have an inline div on my page which horizontally
hi i am integrating authorize.net AIM api into my shopping cart. i have a
There's a status indicator code for AIM which returns two different images depending on
I am building a series of web services in VB.Net Each of the web
Aim: to create user friendly web interface to linux program without any ssh (console)
My aim is to retrieve some data from a global array which is defined
My aim is to retrieve some data from a global array which is defined

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.