Is it possible to pass a value to a DTS defining the path to a file, and somehow using that variable within the DTS transformation to say "the text file is here".
If you set up a global variable and use an initial activex to read the text file, you can then set the properties of the text file connection to use the global variable.
I have got an example of how to do this, but have not got it with me at the moment. I will post it when I am back in the office.
Kevin
**************************************************************
Rock is Dead (Long Live Paper and Scissors)**************************************************************
You can use a Dynamic Properties task to change details of any task at runtime. In your example, you could execute a task which created the dynamic filename using a SQL query (eg, I have used this where the filename will be a certain configuration of a date). --James
Function Main()
'declare variables
dim expect_path, tempPath, txtPath 'various paths: expected path (global variable), path and file name, from the text file
dim txtDB 'database name from text file
dim fso, f1, textstream 'objects for reading the text file
dim oConn 'connection object for the text file
dim stat 'status of package (success or fail)
'set up variables for use
expect_path = DTSGlobalVariables("the_path".value
set fso = createobject("scripting.filesystemobject"
'check the existance of the file path.txt
tempPath = expect_path +"path.txt"
IF (fso.FileExists(tempPath)) THEN
set f1 = fso.getfile(tempPath)
set textstream = f1.openastextstream
txtPath = textstream.ReadLine + "data\"
else
stat = DTSTaskExecResult_Failure
end if
'check the existance of the file database.txt
tempPath = expect_path + "database.txt"
IF (fso.FileExists(tempPath)) THEN
set f1 = fso.getfile(tempPath)
set textstream = f1.openastextstream
txtDB = textstream.ReadLine
else
stat = DTSTaskExecResult_Failure
end if
if stat <> DTSTaskExecResult_Failure then
'change the name and location of the databases
Set oConn = DTSGlobalVariables.Parent.Connections("Microsoft Access"
oConn.DataSource = txtPath + txtDB
Set oConn = DTSGlobalVariables.Parent.Connections("Microsoft Access 2"
oConn.DataSource = txtPath +txtDB
Set oConn = DTSGlobalVariables.Parent.Connections("Microsoft Access 3"
oConn.DataSource = txtPath +txtDB
'report task success
stat = DTSTaskExecResult_Success
end if
Main = stat
End Function
END CODE **************************************************************
Rock is Dead (Long Live Paper and Scissors)**************************************************************
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.