Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
sardinka
Posting Yak Master
142 Posts |
Posted - 2006-11-17 : 09:11:06
|
What am I doing wrong? I am looping though global variables and I have another task where I am sending emails. What I want to do is any of the files were rename send email. but it is not working why?I have on sucess send email.thanksFunction Main()' Convert current date & time Dim strResult,strDay,strMonth,strYear strYear=Right( Year(Now()) , 2 ) If Len (Month(Now()))=1 Then strMonth="0"& Month(Now()) Else strMonth=Month(Now()) End if if Len(Day(Now() )) = 1 then strDay="0" & Day(Now()) Else strDay=Day(Now() ) end if strResult =strMonth & strDay& strYear' Look for FilesDim sPath, gVar,oPackage,sDestinationFile,oFSOSet oPackage = DTSGlobalVariables.ParentsPath="C:\"Set oFSO = CreateObject("Scripting.FileSystemObject") 'Loop through all the Global variables to get the file namesFor Each gVar In oPackage.GlobalVariablesIf Not oFSO.FileExists( sPath & gVar.Value) Then Main=DTSTaskExecResult_Failure Else ' Rename the fileSet oFSO = CreateObject("Scripting.FileSystemObject")oFSO.MoveFile sPath & gVar.Value, sPath & gVar.Value & "_" & strResult & Left( (Replace((FormatDateTime( Now() ,3)) , ":" , "" ) ),6) Main=DTSTaskExecResult_Success End If NextSet oFile = NothingSet oFSO = NothingEnd Function |
|
mwjdavidson
Aged Yak Warrior
735 Posts |
Posted - 2006-11-22 : 08:42:44
|
You're setting the outcome of the task for each iteration of your loop - that ain't right! I'm assuming that it is only when the last iteration is a file that exists that your task will have a successful outcome, allowing the proceeding task to execute.Mark |
|
|
|
|
|
|
|