Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 [VB.Net]-[DTS] Changing the DataSource

Author  Topic 

rpallas
Starting Member

5 Posts

Posted - 2004-12-23 : 06:41:47
Hi, I am trying to use VB.net to run a DTS package that i have created. I have managed to get the VB.net code to successfully execute the package and change two of the global variables dynamically, but i have not been able to dynamically change the DataSource for the csv text file that i am trying to output. I am very new to DTS and SQL, and have very likely made a silly mistake. This is the code i have (i have commented where the problem appears to be):



Dim oPackage As New DTS.Package
Dim oConn

oPackage.LoadFromSQLServer(<Server IP>, <UserName>, <Password>, _
DTS.DTSSQLServerStorageFlags.DTSSQLStgFlag_Default, , , , _
<DTS Package Name>)

For Each oStep As DTS.Step In oPackage.Steps
oStep.ExecuteInMainThread = True
Next

' Remove the global variables.
oPackage.GlobalVariables.Remove(2)
oPackage.GlobalVariables.Remove(1)

oPackage.GlobalVariables.AddGlobalVariable("StartDate", tpStart.Text)
oPackage.GlobalVariables.AddGlobalVariable("EndDate", dtpStart.Text)

' -- **
' This is where my problem is, the following line won't
' compile. But this is how it is done in all the examples i
' have found.
' ** --
' Get Named Connection
oConn = oPackage.Connections("Text File (Destination)")
' Set Filename to new value
oConn.DataSource = txtFile.Text

'Run the package and release references.
oPackage.Execute()
oPackage.UnInitialize()
oPackage = Nothing
oConn = Nothing



Can anyone help? Thanks

-Rob-

nr
SQLTeam MVY

12543 Posts

Posted - 2004-12-23 : 10:21:06
see
http://www.nigelrivett.net/SetDTSRunTimeValues.html


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -