Solved

Dynamically change the filename in a dts package.

Posted on 2007-03-27
4
195 Views
Last Modified: 2013-11-30
I have a dts package that simply imports a text file into an existing sql 2000 table.  What I am trying to find out is how to run this package in VB6.  In addition to running the dts package weekly, the files have a different name each time and the package will need to be able to dynamically change the file name that it is importing via VB6.  How do I do this?
0
Comment
Question by:mhopeman
  • 3
4 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 18810226
It depends what is driving the DTS Package.  Is the name random but always in the same folder?  Is the name passed in or can it be determined?
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 18810233
Also, how are you executing the DTS package from VB6?
0
 

Author Comment

by:mhopeman
ID: 18810300
Actually I am a newbie to this so you will have to bare with me.  I have an existing DTS package that I manually run every week that imports a text file into an existing  SQL table.  I was just notified that I will have more text files that will be needed to be imported into the same table but will not share the same file name but will share the same file structure.  I was told to find a way to run the DTS package in VB and also be able to dynamically change the file name being imported so that I do not have to create a new package for each file.  I would simply use the one original package and just swap file names.  Again, this process is all manual and has yet to be even started in VB.
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 125 total points
ID: 18812821
Ok see if this helps. In order to set the text file name you have a couple of options:
1. Use the Dynamic Properties Task: to set the value of the DataSource property for the text file Connection.
2. (My preference) is to use an ActiveX Script Task to set the same property as in:

Function Main()
Dim Pkg

Set Pkg = DTSGlobalVariables.Parent
Pkg.Connections("Text File Connection Name").DataSource = "The full path to your text file goes here"
Set Pkg = Nothing

Main = DTSTaskExecResult_Success

End Function

In either case, you need to ensure that the workflow is set up so that these tasks are executed before the Transform Data task.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now