I'm setting a textfile as a datasource.
First I have to check if it exists.
The end of the name can change so that's why I have to use a wildcard. Example: OTBRFC-E001_TST00005.txt should be substitude as OTBRFC-E001_TST*.txt
How can I get a wildcard to work?
Function Main()
Dim oConn, sFilename, lobjFSO
' Filename format - exyymmdd
sFilename = "d:\Infile\" & 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=sFilename & "OTBRFC-E001_TST00005.txt"
sFilename = DTSGlobalVariables("LogFilePath").Value & _
sFilename
Set oConn = DTSGlobalVariables.Parent.Connections("Text File (Source)")
oConn.DataSource = sFilename
Set oConn = Nothing
Set lobjFSO = CreateObject("Scripting.FileSystemObject")
If Not lobjFSO.FileExists(sFilename) Then
Main = DTSStepScriptResult_DontExecuteTask
else
Main = DTSTaskExecResult_Success
end if
End Function
First I have to check if it exists.
The end of the name can change so that's why I have to use a wildcard. Example: OTBRFC-E001_TST00005.txt should be substitude as OTBRFC-E001_TST*.txt
How can I get a wildcard to work?
Function Main()
Dim oConn, sFilename, lobjFSO
' Filename format - exyymmdd
sFilename = "d:\Infile\" & 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=sFilename & "OTBRFC-E001_TST00005.txt"
sFilename = DTSGlobalVariables("LogFilePath").Value & _
sFilename
Set oConn = DTSGlobalVariables.Parent.Connections("Text File (Source)")
oConn.DataSource = sFilename
Set oConn = Nothing
Set lobjFSO = CreateObject("Scripting.FileSystemObject")
If Not lobjFSO.FileExists(sFilename) Then
Main = DTSStepScriptResult_DontExecuteTask
else
Main = DTSTaskExecResult_Success
end if
End Function