I am using FB to try to script out SQL Server jobs, check in/out of source control, etc. I'm using VB and the SQL Server DMO library for this purpose. The issue I have is that within the run script action, in the script editor, I am getting conflicting behavior between what telesense indicates and runtime behavior. Looking at the code sample below, you will see the line 'Category = Job.Category'... This code works so, clearly, 'category' is a valid object in the 'job' collection. However, in the run script action script editor, if I type 'job.' to see the telesense list of valid objects and methods in the collection, 'Category' is not listed. Can anyone explain what the issue is with this?
Similarly, I have seen other VB\DMO code samples with job.jobname where 'jobname' is a member fo the job collection. However, again, telesense does not list it. Unlike the the 'category' object, including job.jobname in the code causes a run-time error and an error message indicating that 'jobname' is not part of the collection. I'm not sure why code samples I've been looking at seem to support different collections. Is it a VB version issue?
Suggestions please?
Clive Richardson
***************************
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oSQLServer = CreateObject("SQLDMO.SQLServer2")
oSQLServer.LoginSecure = True
oSQLServer.Connect "SQL1"
idStep = 1
For Each job in oSQLServer.JobServer.Jobs
Category = Job.Category ' not included in telesense but works at runtime.
if Category = "Application" then
'JName = job.JobName
JName = oSQLServer.JobServer.Jobs.Item(idStep).Name
JName = replace(JName, " ","_")
JName = replace(JName, ":","")
JName = replace(JName, ".","")
JName = replace(JName, ",","")
jName = BaseDirectory & "\Target_Server_Job_Scripts\" & JName & ".sql"
Set oFSOWrite = oFSO.OpenTextFile( JName, ForWriting, True)
oFSOWrite.WriteLine job.script
oFSOWrite.Close
end if
idStep = idStep + 1
Next