dbTalk Databases Forums  

Manipulating the DTS.Task object

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Manipulating the DTS.Task object in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
BBM
 
Posts: n/a

Default 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

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.