Solved

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

Posted on 2013-11-10
3
1,053 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

734 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