Hi,
I am developing one web application where I am adding a job to sql server 2005 scheduler programatically . When I run code i m able to add job to schedular but it does not execute on time.
If I create the same job manually, job executes on time.
When saw differences between these two jobs I found out that
Job created manually has following additional value: When I click on 'Job Referencing a Schedule' i see Reference between Schedule and Job created but
but Job created Programatically gives an error as 'Unknown property Id (Microsoft.SqlS erver.SmoEnum)'
I have wasted to much of time on this so please help me to resolve this error.
My code is as follows:
[code=cpp]
Server srv = default(Server) ;
SqlConnectionIn fo connInfo = new SqlConnectionIn fo("(local)", "sa", "1234");
connInfo.Databa seName = "uhl_50";
Microsoft.SqlSe rver.Management .Common.ServerC onnection svrConn = new ServerConnectio n(connInfo);
srv = new Server(svrConn) ;
JobServer jbSrv = srv.JobServer;
Job jb = new Job(jbSrv, "Test_Job5" );
jb.Create();
JobStep jbstp = default(JobStep );
jbstp = new JobStep(jb, "Test_Job_Step5 ");
jbstp.SubSystem = AgentSubSystem. TransactSql ;
jbstp.Command = @"insert into uhl_50.dbo.jobt est values ('kal')";
jbstp.OnSuccess Action = StepCompletionA ction.QuitWithS uccess;
jbstp.OnFailAct ion = StepCompletionA ction.QuitWithF ailure;
//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 = default(JobSche dule);
jbsch = new JobSchedule(jb, "Test_Job_Sched ule5");
//Set properties to define the schedule frequency, and duration.
jbsch.Frequency Types = FrequencyTypes. OneTime;
TimeSpan ts1 = default(TimeSpa n);
ts1 = new TimeSpan(18, 18, 0);
jbsch.ActiveSta rtTimeOfDay = ts1;
System.DateTime d = default(System. DateTime);
d = new System.DateTime (2008, 11, 17);
jbsch.ActiveSta rtDate = d;
jbsch.Create();
jbsch.Refresh() ;[/code]
I am developing one web application where I am adding a job to sql server 2005 scheduler programatically . When I run code i m able to add job to schedular but it does not execute on time.
If I create the same job manually, job executes on time.
When saw differences between these two jobs I found out that
Job created manually has following additional value: When I click on 'Job Referencing a Schedule' i see Reference between Schedule and Job created but
but Job created Programatically gives an error as 'Unknown property Id (Microsoft.SqlS erver.SmoEnum)'
I have wasted to much of time on this so please help me to resolve this error.
My code is as follows:
[code=cpp]
Server srv = default(Server) ;
SqlConnectionIn fo connInfo = new SqlConnectionIn fo("(local)", "sa", "1234");
connInfo.Databa seName = "uhl_50";
Microsoft.SqlSe rver.Management .Common.ServerC onnection svrConn = new ServerConnectio n(connInfo);
srv = new Server(svrConn) ;
JobServer jbSrv = srv.JobServer;
Job jb = new Job(jbSrv, "Test_Job5" );
jb.Create();
JobStep jbstp = default(JobStep );
jbstp = new JobStep(jb, "Test_Job_Step5 ");
jbstp.SubSystem = AgentSubSystem. TransactSql ;
jbstp.Command = @"insert into uhl_50.dbo.jobt est values ('kal')";
jbstp.OnSuccess Action = StepCompletionA ction.QuitWithS uccess;
jbstp.OnFailAct ion = StepCompletionA ction.QuitWithF ailure;
//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 = default(JobSche dule);
jbsch = new JobSchedule(jb, "Test_Job_Sched ule5");
//Set properties to define the schedule frequency, and duration.
jbsch.Frequency Types = FrequencyTypes. OneTime;
TimeSpan ts1 = default(TimeSpa n);
ts1 = new TimeSpan(18, 18, 0);
jbsch.ActiveSta rtTimeOfDay = ts1;
System.DateTime d = default(System. DateTime);
d = new System.DateTime (2008, 11, 17);
jbsch.ActiveSta rtDate = d;
jbsch.Create();
jbsch.Refresh() ;[/code]
Comment