0

I'm trying to programmatically create an 'Excute Package Task' in SSIS using Visual Basic. However I can't get it to work with UseProjectReference = True. The package doesnt fail but nothing happens. Am I missing some other property? Here is the code

Public Sub Main()
    Dim ExecResult As DTSExecResult = DTSExecResult.Failure
    Dim p As Package = New Package       
    Dim exec As Executable = p.Executables.Add("STOCK:ExecutePackageTask")
    Dim th As TaskHost = CType(exec, TaskHost)
    th.Properties("Name").SetValue(th, "Execute Package")
    th.Properties("Description").SetValue(th, "Execute Package")
    th.Properties("UseProjectReference").SetValue(th, "True")
    th.Properties("PackageName").SetValue(th, "Test.dtsx")
    th.Properties("ExecuteOutOfProcess").SetValue(th, "False")    
    ExecResult = p.Execute()
    p.Dispose() 
    Dts.TaskResult = ScriptResults.Success
End Sub

The below code works successfully calling the package from the file system, however as I mentioned I need the package called from the project.

Public Sub Main()
    Dim ExecResult As DTSExecResult = DTSExecResult.Failure
    Dim SIFISO_app As Application = New Application
    Dim p As Package = New Package
    Dim cm_DES As ConnectionManager = p.Connections.Add("FILE")
    cm_DES.Name = "local_pkg"
    cm_DES.ConnectionString = String.Format("C:\Test.dtsx")
    Dim exec As Executable = p.Executables.Add("STOCK:ExecutePackageTask")
    Dim th As TaskHost = CType(exec, TaskHost)
    th.Properties("Name").SetValue(th, "Execute selectSIFISO Package")
    th.Properties("Description").SetValue(th, "Execute selectSIFISO Package")
    th.Properties("Connection").SetValue(th, "local_pkg")
    th.Properties("ExecuteOutOfProcess").SetValue(th, "False")
    ExecResult = p.Execute()
    p.Dispose()
    Dts.TaskResult = ScriptResults.Success
End Sub
djv
  • 15,168
  • 7
  • 48
  • 72
DC07
  • 293
  • 5
  • 18

1 Answers1

0

Well as a Work around, I save the package to disk with project reference set as true and then load the package to SSISDB with the below code. Not exactly what I wanted, but works how I wanted.

        ' Before deploying packages, make sure the destination project exists in SSISDB.  
    Dim connectionString As String = "Data Source=localhost;Integrated Security=True;MultipleActiveResultSets=false"
    Dim catalogName As String = "SSISDB"
    Dim folderName As String = "Test"
    Dim projectName As String = "Test"
    ' Get the folder instance.  
    Dim sc As SqlConnection = New SqlConnection(connectionString)
    Dim store As New Microsoft.SqlServer.Management.IntegrationServices.IntegrationServices(sc)
    Dim folder As CatalogFolder = store.Catalogs(catalogName).Folders(folderName)
    ' Key is package name without extension and value is package binaries.  
    Dim packageDict As New Dictionary(Of String, String)()

    Dim packageData As String
    packageData = My.Computer.FileSystem.ReadAllText("C:\Package7.dtsx")
    packageDict.Add("Package7", packageData)

    ' Deploy package to the destination project.  
    folder.DeployPackages(projectName, packageDict)
DC07
  • 293
  • 5
  • 18