Cannot run job created by SMO
I've create a SQL Agent job using C# SMO to process an Analysis Service Database (see code below). When I tried to start job from Management Studio, I get the following error message...any ideas?
TITLE: Microsoft.SqlServer.Smo
Start failed for Job 'Schedule Job OLAPProj'.
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
Cannot start the job "Schedule Job OLAPProj" (ID 089BEE15-B060-466E-B59E-7F7DAB1EB8DB) because it does not have any job server or servers defined. Associate the job with a job server by calling sp_add_jobserver. (Microsoft SQL Server, Error: 14256)
Common. ServerConnection l_oServerConn =new Common.ServerConnection();l_oServerConn.ServerInstance = txtServer.Text; l_oServerConn.LoginSecure = true;l_oServerConn.Connect(); Smo. Server l_oServer =new Smo.Server(l_oServerConn);Agent. Job l_oJob =new Agent.Job(l_oServer.JobServer,"Schedule Job " + cboDB.Text);l_oJob.IsEnabled = true;l_oJob.Description = "Schedule Job Processing OLAP Cube: " + cboDB.Text;l_oJob.OwnerLoginName = @"NT AUTHORITY\SYSTEM";l_oJob.Create(); Agent. JobStep l_oJobStep =new Agent.JobStep(l_oJob,"Process " + cboDB.Text);l_oJobStep.SubSystem = Agent. AgentSubSystem.AnalysisCommand;string l_sCmd =@"<Process xmlns=""http://schemas.microsoft.com/analysisservices/2003/engine"">";l_sCmd = l_sCmd + "<Object><DatabaseID>" + cboDB.Text +"</DatabaseID></Object><Type>ProcessFull</Type>";l_sCmd = l_sCmd + "<WriteBackTableCreation>UseExisting</WriteBackTableCreation></Process>";l_oJobStep.Command = l_sCmd; l_oJobStep.Server = txtServer.Text; l_oJobStep.DatabaseName = @"master";l_oJobStep.JobStepFlags = Agent. JobStepFlags.AppendToJobHistory;l_oJobStep.OnSuccessAction = Agent. StepCompletionAction.QuitWithSuccess;l_oJobStep.OnFailAction = Agent. StepCompletionAction.QuitWithFailure;l_oJobStep.Create(); |

