0

I have static table that has the has something like this: xy_Jan10 yz_Feb11 xx_March14 by_Aug09 etc. these names are static and they are stored in a table. I am using ForEachLoop container, so first i am reading and saving all the static names that i mentioned above into an system object variable. Next i am using the ForeachLoop containter and looping through for each of the file name and saving it into another string variable called strFileName. So in my for each loop container, i have script task that checks first if the file exists and here is where i have the problem, for each file name that comes to the variable i want to check if that file name exist firs, if exists i want to load it into my table, if not exist then i want to check the next file name, if next file name does not exist then i want to check the next variable name inline and so on. I only want to load if the variable file name matches the files on the network drive, if it is not found then i want to check next one until i go through each one in my static list names. My issue now script task stops when there is no match with the file names but i want it to go to the next variable name in the list and load it because there are a lot of other matches that are not loaded. the script task stops at the first one where it finds non much. Here is my script task: please not the files i am loading are SAS files.

 Public Sub Main()
        '
        ' Add your code here
        '

        Dim directory As DirectoryInfo = New DirectoryInfo("\\840KLM\DataMart\CPTT\Cannon")
        Dim file As FileInfo() = directory.GetFiles("*.sas7bdat")

        If file.Length > 0 Then
            Dts.Variables("User::var_IsFileExist").Value = True
        Else
            Dts.Variables("User::var_IsFileExist").Value = False
        End If
        Dts.TaskResult = ScriptResults.Success

    End Sub
moe
  • 5,149
  • 38
  • 130
  • 197

1 Answers1

0

It looks like you need to wrap the script task inside a ForEach loop container. There's plenty of information about how to do this on the web, or even on Stack Overflow: How to loop through Excel files and load them into a database using SSIS package?

or

http://www.sqlis.com/sqlis/post/Looping-over-files-with-the-Foreach-Loop.aspx

Community
  • 1
  • 1
Greg the Incredulous
  • 1,676
  • 4
  • 29
  • 42