Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Executing and monitoring jobs using SMO

Author  Topic 

rajkrish
Starting Member

1 Post

Posted - 2008-07-22 : 02:17:59
Hi,

I am starting a SQL agent job and monitoring the same using SMO.
Here is the code.

Jobprocess.Start();
//wait to start the job
while (Jobprocess.CurrentRunStatus == JobExecutionStatus.Idle)
{
//sleep
System.Threading.Thread.Sleep(100);
Jobprocess.Refresh();
}

while (Jobprocess.CurrentRunStatus == JobExecutionStatus.Executing)
{
//sleep
System.Threading.Thread.Sleep(100);
Jobprocess.Refresh();
}
after few steps it returns an exception "Specified cast is not valid". It throws exception at different job steps.

Appreciate your help.
   

- Advertisement -