Manipulating the DTS.Task object -
06-20-2005
, 07:29 PM
I have a situation where I'd like to just change the file names in a DTS
Transform.
From a VB.Net application, the user enters a filename and the system changes
the
SourceSQLStatement to include the name input by the user.
I have a pre-built DTS package that is correct in all respects except for
the source filename. I'm thinking I can just load it, change the
SourceSQLStatement property in the appropriate DTS.Task objects, and execute
the package.
My code looks like this...
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim idx As System.Collections.IEnumerator
Dim cTask As DTS.Task
Dim dTask As DTS.DataPumpTask2
Dim wrkstr As String
Dim dtsp As New DTS.Package
dtsp.LoadFromSQLServer("STEVE", , ,
DTSSQLServerStorageFlags.DTSSQLStgFlag_UseTrustedC onnection, , , , "MySource")
idx = dtsp.Tasks.GetEnumerator()
idx.MoveNext() ' the first task creates
a "target" table
idx.MoveNext() ' this is the "copy" task
cTask = CType(idx.Current(), DTS.Task)
dTask = cTask.CustomTask
wrkstr = dTask.SourceSQLStatement
wrkstr.Replace("MySource", "InputString")
dTask.SourceSQLStatement = wrkstr
dtsp.Execute()
End Sub
my attempt to cast the cTask.CustomTask object to a DTS.DataPumpTask2 fails no
matter how I try it.
Is it possible to do this (change the SourceSQLStatement for a DTS packate
from VB) and what is the syntax?
Thanks.
BBM |