Editing DTS package through .NET

  • are there any examples out there to edit a DTS package using .NET (either VB or C#)?  I am trying to edit a ExecuteSQLTask2  inside a packge object (using Gert Drapers method of executing DTS through .NET).  i can instantiate and execute the package, but cannot access the tasks inside the package.  my goal is to load the package, access an ExecuteSQLTask2 task, edit the sql text, and either save/execute the package.

    any help/links would be appreciated.

     

     

  • Try using something like what is shown below in an ActiveX Script task.

    You should be able to apply this concept to any task.

    (Also, check out http://www.SQLDTS.com)

    Option Explicit

     

    Function Main()

     

                Dim objPkg

                Dim objDataPump

                Dim mySQL

     

                'Alter SQL statement

                mySQL = "SELECT …"

     

                ' Get reference to the DataPump Task

                Set objPkg = DTSGlobalVariables.Parent

                Set objDataPump = objPkg.Tasks("DTSTask_DTSDataPumpTask_1").CustomTask

     

                ' Assign SQL Statement to Source of DataPump

                objDataPump.SourceSQLStatement = mySQL

     

                ' Clean Up

                Set objDataPump = Nothing

                Set objPkg = Nothing

     

                Main = DTSTaskExecResult_Success

     

    End Function

     

     

  • Here is an example in how to use dts on .net

    http://www.sqldev.net/dts/DotNETCookBook.htm

    Regards

    JFB

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply