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

  • SEARCH
  • Home
  • 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 7602735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:29:15+00:00 2026-05-30T23:29:15+00:00

What I want to do, is to schedule a SSIS package, using C#. the

  • 0

What I want to do, is to schedule a SSIS package, using C#. the missing part is, how to tell the agent that this schedulare is for the SSIS package “X”, Here is my code :

Server srv = new Server();

//Define an Operator object variable by supplying the Agent (parent JobServer object) and the name in the constructor. 
Operator op = new Operator(srv.JobServer, "AC_Operator") { NetSendAddress = "Network1_PC" };

//Create the operator on the instance of SQL Server Agent. 
op.Create();

//Define a Job object variable by supplying the Agent and the name arguments in the constructor and setting properties. 
Job jb = new Job(srv.JobServer, "AC_Job");

//Specify which operator to inform and the completion action. 
jb.OperatorToNetSend = "AC_Operator";
jb.NetSendLevel = CompletionAction.Always;

//Create the job on the instance of SQL Server Agent. 
jb.Create();

//Define a JobStep object variable by supplying the parent job and name arguments in the constructor. 
JobStep jbstp = new JobStep(jb, "AC_Job_Step");
jbstp.OnSuccessAction = StepCompletionAction.QuitWithSuccess;
jbstp.OnFailAction = StepCompletionAction.QuitWithFailure;

//Create the job step on the instance of SQL Agent. 
jbstp.Create();

//Define a JobSchedule object variable by supplying the parent job and name arguments in the constructor. 

JobSchedule jbsch = new JobSchedule(jb, "AC_Job_Schedule");

//Set properties to define the schedule frequency, and duration. 
jbsch.FrequencyTypes = FrequencyTypes.Daily;
jbsch.FrequencySubDayTypes = FrequencySubDayTypes.Minute;
jbsch.FrequencySubDayInterval = 30;
TimeSpan ts1 = new TimeSpan(9, 0, 0);
jbsch.ActiveStartTimeOfDay = ts1;

TimeSpan ts2 = new TimeSpan(17, 0, 0);
jbsch.ActiveEndTimeOfDay = ts2;
jbsch.FrequencyInterval = 1;

DateTime d = new DateTime(2003, 1, 1);
jbsch.ActiveStartDate = d;

//Create the job schedule on the instance of SQL Agent. 
jbsch.Create();

Thanks for your time.

  • 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-30T23:29:16+00:00Added an answer on May 30, 2026 at 11:29 pm

    What you are needing to do is set the jobstep’s SubSystem and then build your Command. In comparing the .NET generated code to a SQL Agent created job, the only difference I noticed was the assignment of the DatabaseName property so I set that as well.

    You’ll also undoubtedly want to look at dtexec to figure out how to configure and invoke your package or you can cheat like I do and use dtexecui or the Agent to build out the SET and other commands and then paste those in as the source command.

            //Define a JobStep object variable by supplying the parent job and name arguments in the constructor. 
            JobStep jbstp = new JobStep(jb, "AC_Job_Step");
            jbstp.OnSuccessAction = StepCompletionAction.QuitWithSuccess;
            jbstp.OnFailAction = StepCompletionAction.QuitWithFailure;
    
            string command = string.Empty;
            command = @"/FILE ""C:\sandbox\SSISHackAndSlash2008\SSISHackAndSlash2008\EzAPI_Recipe01.dtsx""  /CHECKPOINTING OFF /REPORTING E";
            jbstp.SubSystem = AgentSubSystem.Ssis;
            jbstp.DatabaseName = "master";
            jbstp.Command = command;
    
            //Create the job step on the instance of SQL Agent. 
            jbstp.Create();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to schedule job that would run immediately once the server is up,
In SQL Server 2005, is it possible to schedule an SSIS package to run
I have scheduled sql agent task which runs an SSIS package. I want to
I am using the amazonaws es3 server.I want to schedule my cron with command
I want to schedule the email with asp.net and C# code. what is basic
I am running a SVN server on my Windows Server and want to schedule
I want to automate a Windows 2000+ server reboot process using Task Scheduler or
I want to schedule a job in Jboss and websphere server. I have a
I want to schedule a @selector(count) interval: 1.0f to count the time left. here
I am using the Grails Quartz plugin and want to schedule my jobs with

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.