Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DTS Parameter from VB4

Status
Not open for further replies.

consuelo

Programmer
Aug 27, 2003
1
VE
Hi

I have a DTS with a SQL in it, in the clause WHERE there are a range of date (FROM/TO), these value is always change to edit the SQL and update it manuality

I have a VB project where the user types the values FROM/TO and then push the buttom to execute the procedure.

i need to execute the DTS from VB, transfer the values (from/to), and the DTS must to catch the value and run the procedure.

How i can to do:

1.- how can i build the sql ??? (select * from table where range1 = ??? and range2 = ????)
2.- what would i do in VB to send the values.

Please help me!!! and forget my bad english



 
Simply put...

1 - Create two DTS global variables: one for FROM, one for TO.

2 - Change the SELECT to use the FROM and TO global variables instead of hard-coded values.

3 - In VB, set the value of the FROM and TO global variables prior to executing the packge.

How does this work for you?

--Angel [rainbow]
-----------------------------------
Every time I lose my mind, I wonder
if it's really worth finding.
 
For VB6
Reference the dtspkg.dll

Dim objPackage As DTS.Package2

'Instanciate the DTS package object
Set objPackage = New DTS.Package2

'Set the server/username/password and the DTS package to be run objPackage.LoadFromSQLServer "Server", "Login_User", "Login_Password", DTSSQLStgFlag_Default, "", "", "", "DTS_Package_Name"

'Pass the date values to the DTS Package
objPackage.GlobalVariables("FromDate").Value = dtpFrom.Value
objPackage.GlobalVariables("ToDate").Value = dtpTo.Value

'Set object to raise an error on failure and to do eventlogs
objPackage.FailOnError = True
objPackage.WriteCompletionStatusToNTEventLog = True

'Run DTS Package
objPackage.Execute

Hope this will help

[flowerface]


"All I ask is the chance to prove that money can't make me happy." - Spike Milligan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top