Run SSIS package from VB.NET
By Allen Stoner
Run a SSIS package from in VB.NET code with a configuration parameter specified.
Private Sub Run_SSIS()
Dim SSISPackagePath As String = "c:\source\SSISPackage.dtsx"
Dim sMessage As String = ""
Dim pkg As New Package
Dim app As New Application
Dim pkgResults As DTSExecResult
pkg = app.LoadPackage(SSISPackagePath, Nothing)
pkg.EnableConfigurations = True
' Create the configuration reference
Dim Config As Configuration = pkg.Configurations.Add
Config.Name = "Configuration"
Config.ConfigurationType = SSISConfigurationType.ConfigFile
Config.ConfigurationString = "c:\source\SSISConfig.config"
pkgResults = pkg.Execute()
Dim warning As DTSWarning
If pkgResults > DTSExecResult.Success Then
For Each warning In pkg.Warnings
sMessage = "Step " & warning.SubComponent & " Failed - " & _
" - Error: " & warning.WarningCode & _
" - Source: " & warning.Source & _
" - Description: " & warning.Description
Next
End If
If Len(sMessage) > 0 Then
Throw New Exception("SSIS error: " & sMessage)
End If
End Sub
Run SSIS package from VB.NET (2362 Views)