dbTalk Databases Forums  

DTS: File Name Change??

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


Discuss DTS: File Name Change?? in the microsoft.public.sqlserver.dts forum.



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

Default DTS: File Name Change?? - 10-21-2004 , 12:09 AM






Hi,
Can someone help me with the following

I get a file each week with different name. Using Nothwind
Example. Suppose I get a file CustomersA1. Next week I get the file with
the name CustomersA8. This file that I get each week has to go in Customers
table .
How do I tell DTS that the file name changes every week. I am using Text
file connection & I have specified the file name.
For example
C:\Work\customersA1.txt

Earlier I had posted it few days ago & I was refered to a website which had
following code.

'************************************************* *********************
' Visual Basic ActiveX Script
'************************************************* ***********************

Function Main()
Dim oConn, sFilename
sFilename = "customer" & Right(Year(Now()), 2)
If Month(Now()) < 10 Then sFilename = sFilename & "0" & Month(Now()) Else
sFilename = sFilename & Month(Now())
If Day(Now()) < 10 Then sFilename = sFilename & "0" & Day(Now()) Else
sFilename = sFilename & Day(Now())
sFilename = DTSGlobalVariables("FilePath").Value & sFilename & ".txt"
Set oConn = DTSGlobalVariables.Parent.Connections("Text File (Source)")
oConn.DataSource = sFilename
set oConn = Nothing
Main = DTSTaskExecResult_Success
End Function


I am not good in activex programming. I am just a beginner in activex. Can
someone show me with syntax(activex) what to write in order to determine that
filename has changed.


A complete syntax will be lot of help for me. Please use
C:\Work\filename.txt as path so I can understand it well




Thanks

Steve

Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: File Name Change?? - 10-21-2004 , 03:36 PM






OK.

To be able to use any code to automagically rename the file connection to
the correct one you have to be able to perform the logic to derive that
name. Can you? How do you _KNOW_ what the file will be called.

--
--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
www.konesans.com - Consultancy from the people who know


"Steve" <Steve (AT) discussions (DOT) microsoft.com> wrote

Quote:
Hi,
Can someone help me with the following

I get a file each week with different name. Using Nothwind
Example. Suppose I get a file CustomersA1. Next week I get the file with
the name CustomersA8. This file that I get each week has to go in
Customers
table .
How do I tell DTS that the file name changes every week. I am using Text
file connection & I have specified the file name.
For example
C:\Work\customersA1.txt

Earlier I had posted it few days ago & I was refered to a website which
had
following code.

'************************************************* *********************
' Visual Basic ActiveX Script
'************************************************* ***********************

Function Main()
Dim oConn, sFilename
sFilename = "customer" & Right(Year(Now()), 2)
If Month(Now()) < 10 Then sFilename = sFilename & "0" & Month(Now()) Else
sFilename = sFilename & Month(Now())
If Day(Now()) < 10 Then sFilename = sFilename & "0" & Day(Now()) Else
sFilename = sFilename & Day(Now())
sFilename = DTSGlobalVariables("FilePath").Value & sFilename & ".txt"
Set oConn = DTSGlobalVariables.Parent.Connections("Text File (Source)")
oConn.DataSource = sFilename
set oConn = Nothing
Main = DTSTaskExecResult_Success
End Function


I am not good in activex programming. I am just a beginner in activex.
Can
someone show me with syntax(activex) what to write in order to determine
that
filename has changed.


A complete syntax will be lot of help for me. Please use
C:\Work\filename.txt as path so I can understand it well




Thanks

Steve



Reply With Quote
  #3  
Old   
Wm. Scott Miller
 
Posts: n/a

Default Re: File Name Change?? - 10-21-2004 , 03:45 PM



See the loop example at http://www.sqldts.com/default.aspx?246

We use it to download files from FTP site, loop through all files downloaded
and process them into our tables. Works like a champ and we don't care the
file name because we get is from each file right before we process. We then
delete the file if success or move to an error directory if failure. We
have modified the example they provide to our needs as can you.

Scott

"Steve" <Steve (AT) discussions (DOT) microsoft.com> wrote

Quote:
Hi,
Can someone help me with the following

I get a file each week with different name. Using Nothwind
Example. Suppose I get a file CustomersA1. Next week I get the file with
the name CustomersA8. This file that I get each week has to go in
Customers
table .
How do I tell DTS that the file name changes every week. I am using Text
file connection & I have specified the file name.
For example
C:\Work\customersA1.txt

Earlier I had posted it few days ago & I was refered to a website which
had
following code.

'************************************************* *********************
' Visual Basic ActiveX Script
'************************************************* ***********************

Function Main()
Dim oConn, sFilename
sFilename = "customer" & Right(Year(Now()), 2)
If Month(Now()) < 10 Then sFilename = sFilename & "0" & Month(Now()) Else
sFilename = sFilename & Month(Now())
If Day(Now()) < 10 Then sFilename = sFilename & "0" & Day(Now()) Else
sFilename = sFilename & Day(Now())
sFilename = DTSGlobalVariables("FilePath").Value & sFilename & ".txt"
Set oConn = DTSGlobalVariables.Parent.Connections("Text File (Source)")
oConn.DataSource = sFilename
set oConn = Nothing
Main = DTSTaskExecResult_Success
End Function


I am not good in activex programming. I am just a beginner in activex.
Can
someone show me with syntax(activex) what to write in order to determine
that
filename has changed.


A complete syntax will be lot of help for me. Please use
C:\Work\filename.txt as path so I can understand it well




Thanks

Steve



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.