December 10, 2004 at 8:50 am
Hi all,
What's the sp_OAMethod syntax for this line of VB:
SQLServer.JobServer.Jobs.Add SQLJob
Thanks,
P
December 13, 2004 at 8:00 am
This was removed by the editor as SPAM
December 13, 2004 at 11:34 am
you can also use sp_add_job
December 13, 2004 at 12:05 pm
Thanks for the reply.
I know I can use sp_add_job, except I have to run that on the SQL Server I want the job added to first. Using DMO, I can connect to whichever server(s) I want, and do it that way, which for my situation is **way** simpler.
P
December 13, 2004 at 7:07 pm
sp_oamethod @objecthandle, 'Add'
Need a handle the the Jobs object before you can do this.
December 14, 2004 at 7:20 am
Hi Steve,
Thanks for the reply.
So in my case, @ObjectHandle = reference to the jobs collection object? I've tried that, and I kept getting and error.
Here's the rest of the example. Prior to this, I've got a handle on the SQLServer object, JobServer object, and the Jobs collection.
/* Create new job object */
EXECUTE @nErrorVar = dbo.sp_OACreate 'SQLDMO.Job', @nJobVarOUTPUT
IF @nErrorVar 0
BEGIN
EXECUTE dbo.sp_OAGetErrorInfo @nJobVar
RETURN
END
/* Set the job's name */
EXECUTE @nErrorVar = dbo.sp_OASetProperty @nJobVar, 'Name', 'Test'
IF @nErrorVar 0
BEGIN
EXECUTE dbo.sp_OAGetErrorInfo @nJobVar
RETURN
END
/* Add the job to the collection */
/* This is where this keeps failing. The error is either Invalid number of parameters, or something about unable to reference object until it's parent has been initialized or something like that. */
EXECUTE @nErrorVar = dbo.sp_OAMethod @nJobsCollVar, 'Add'
IF @nErrorVar 0
BEGIN
EXECUTE dbo.sp_OAGetErrorInfo @nJobsCollVar
RETURN
END
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply