Click here to Skip to main content
15,896,726 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends,

I am using a web application to run the "SSIS Job".

Server sqlServer = new Server(serverConnection);
 JobServer sqlAgent = sqlServer.JobServer;
           Job sqlJob = sqlAgent.Jobs[JobRun];
           JobHistoryFilter jobFilter = new JobHistoryFilter();
           jobFilter.JobName = JobRun;

  sqlJob.Start();


The code is working fine. Now I need to Schedule a job for a particular time. How do I set the time for a particular job to run.

Thanks in advance.
Posted
Updated 24-Aug-10 8:31am
v3

1 solution

In this MSDN documentation [^], I found the following snippet:

Server srv = new Server("(local)");
Job jb = new Job(srv.JobServer, "Test Job");
jb.Create();
JobSchedule jbsch = new JobSchedule(jb, "Test Job Schedule");
jbsch.FrequencyTypes = FrequencyTypes.Daily;
jbsch.FrequencySubDayTypes = FrequencySubDayTypes.Minute;
jbsch.FrequencySubDayinterval = 30;
Timespan ts1 = new Timespan(9, 0, 0);
Timespan ts2 = new Timespan(17, 0, 0);
jbsch.ActiveStartTimeOfDay = ts1;
jbsch.ActiveEndTimeOfDay = ts2;
jbsch.FequencyInterval = 1;
DateTime d = new DateTime(2004, 1, 1);
jbsch.ActiveStartDate = d;
jbsch.Create();
Console.WriteLine(jb.Schedules.ToString());


Is this, what you are looking for?

Cheers
Uwe
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900