How to manage SQL Server Agent jobs through Csharp

Please note this is an expansion to the article on HOW TO ALLOW A USER WITH AN SQL LOGIN TO MANAGE SQL SERVER AGENT.

The entire source code, with comments, for this tutorial can be downloaded here.

in the mentioned article we learnt how to set up an SQL user to manage SQL Jobs, in this article we are going to learn how to manage jobs through a C# application,
and we will be using the SQL user created in the mentioned article to connect to the database and actually mange the SQL Server Agent jobs.

  1. We will be creating a class library named “SQLServerJobUtility” which will contain the functionality required to manage SQL Server Agent jobs
  2. We will be creating a console application to make use of this class library

Please NOTE: SQL Server 2008 R2 or later must be installed on your development machine.

What tools am I using ?

  1. Microsoft Visual Studios 2012
  2. Microsoft SQL Server 2012 with Management studio

Read more “How to manage SQL Server Agent jobs through Csharp”