Posted: 4/25/2012
Hi Guys,
Saw this neat article in MSDN that I wanted to modify so that rather than running a package from the C drive, it would call the package stored in SSIS. Played around with it for a while but can't get it to work. If someone can show me to modify the dtexeArgs variable to point to SSIS with a package called 'Test.dtsx' as an example, that would be great. Other suggestions would also be appreciated.
cheers
Sam
http://msdn.microsoft.com/en-us/library/ms135917.aspx
Dim dtexecArgs As String Dim dataReaderName As String Dim countryName As String Dim dtsConnection As DtsConnection Dim dtsCommand As DtsCommand Dim dtsDataReader As IDataReader Dim dtsParameter As DtsDataParameter Windows.Forms.Cursor.Current = Cursors.WaitCursor dtexecArgs = "/FILE ""C:\...\DtsClientWParamPkg.dtsx""" <<<<<<<THIS argument dataReaderName = "DataReaderDest" countryName = "Canada" dtsConnection = New DtsConnection() With dtsConnection .ConnectionString = dtexecArgs .Open() End With dtsCommand = New DtsCommand(dtsConnection) dtsCommand.CommandText = dataReaderName dtsParameter = New DtsDataParameter("Country", DbType.String) dtsParameter.Direction = ParameterDirection.Input dtsCommand.Parameters.Add(dtsParameter) dtsParameter.Value = countryName dtsDataReader = dtsCommand.ExecuteReader(CommandBehavior.Default) With dtsDataReader .Read() txtResults.Text = .GetInt32(0).ToString("N0") End With 'After reaching the end of data rows, ' call the Read method one more time. Try dtsDataReader.Read() Catch ex As Exception MessageBox.Show("Exception on final call to Read method:" & ControlChars.CrLf & _ ex.Message & ControlChars.CrLf & _ ex.InnerException.Message, "Exception on final call to Read method", _ MessageBoxButtons.OK, MessageBoxIcon.Error) End Try ' The following method is a best practice, and is ' required when using DtsDataParameter objects. dtsCommand.Dispose() Try dtsDataReader.Close() Catch ex As Exception MessageBox.Show("Exception closing DataReader:" & ControlChars.CrLf & _ ex.Message & ControlChars.CrLf & _ ex.InnerException.Message, "Exception closing DataReader", _ MessageBoxButtons.OK, MessageBoxIcon.Error) End Try Try dtsConnection.Close() Catch ex As Exception MessageBox.Show("Exception closing connection:" & ControlChars.CrLf & _ ex.Message & ControlChars.CrLf & _ ex.InnerException.Message, "Exception closing connection", _ MessageBoxButtons.OK, MessageBoxIcon.Error) End Try Windows.Forms.Cursor.Current = Cursors.Default