Next Run Date and Runnable Option in Job Scheduler is Null using SQLServer.Smo
Hi ,
I created a JOB Scheduling for Automatic DB backup in SQL server Agent using Microsoft.Sqlserver.Smo.
I followed all the step mentioned in msdn for creating job programmatically.
I used C# code for this.
Here are the step I used.
Create JOB object , Create Job Step then Job Scheduler.
Job is created everything is created successfully but when I see this job in Job Activity monitor it's next run date is coming null and Runnable option is coming No.Because of this my scheduler is not executing.
If I create a job manually through wizard the next date is populating and runnable is yes ad it is working fine. I did comparasion both of the jobs but didn't get any difference.
Can any one please help me to figure out this as I waste complete one day for thi

Roei BarRank #1,271 · 1.4K reputationPosted Sep 16, 2009, 10:41 AM EDT
//Connect to the local, default instance of SQL Server. 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, "Test_Operator"); //Set the Net send address. op.NetSendAddress = "Network1_PC"; //Create the operator on the instance of SQL 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, "Test_Job"); //Specify which operator to inform and the completion action. jb.OperatorToNetSend = "Test_Operator"; jb.NetSendLevel = CompletionAction.Always; //Create the job on the instance of SQL Agent. jb.Create(); //Define a JobStep object variable by supplying the parent job and name arguments in the constructor. JobStep jbstp = new JobStep(jb, "Test_Job_Step"); jbstp.Command = "Test_StoredProc"; 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, "Test_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; Date d = new Date(2003, 1, 1); jbsch.ActiveStartDate = d; //Create the job schedule on the instance of SQL Agent. jbsch.Create();