Solved

How to trigger and find status of sql job through c#?

Posted on 2013-11-10
3
1,083 Views
Last Modified: 2013-11-30
I have an requirement in which SQL server job needs to be trigger through C# and show the status in web application from its start to end.

SQL server job has to fetch data from excel file and loading it to the SQL Server 2008 R2 database which has minimum of 25000 rows and maximum of any.

Please help in resolve this.

Thanks in advance.
0
Comment
Question by:devmasters
[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
  • 2
3 Comments
 
LVL 23

Expert Comment

by:Michael Fowler
ID: 39637764
If you create the sql job as a stored procedure you can then use print statements in the proc to provide updates to the web app

http://www.nullskull.com/faq/1131/view-print-statements-in-your-stored-procedures-in-c-via-adonet.aspx

Michael
0
 

Accepted Solution

by:
devmasters earned 0 total points
ID: 39676664
SqlConnection DbConn = new SqlConnection(sqlConnection);
            SqlCommand ExecJob = new SqlCommand();
            ExecJob.Connection = DbConn;
            ExecJob.CommandType = CommandType.StoredProcedure;
            ExecJob.CommandText = "msdb.dbo.sp_start_job";
            ExecJob.Parameters.AddWithValue("@job_name", "LoadData");

            using (DbConn)
            {
                DbConn.Open();
                using (ExecJob)
                {
                    ExecJob.ExecuteNonQuery();
                }
            }
0
 

Author Closing Comment

by:devmasters
ID: 39686702
It is perfectly working as expected
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

628 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