ssis parckage is not cherking if the file exist or not

  • I have a ssis parckage wish is reading from flat files and I have a script to cherck if the file exists or not.

    The parckage was workin fine the last time I saved it but if I open and rerun it now it does not cherck the files.sometimes it says files exist by setting the bulean value of the variable FileExist to true even if the file does not exist sometimes it does not.I don't know how does this happen.

    anyone who might know this kind of problem.

    I would appreciate help.

    Regards

    Guy

  • it would be helpful if you posted the script that you are using to check if the file exists.

    another thought, as opposed to using a custom script woud be to use the For Each Loop Container and setting the collection to use the Foreach File Enumeration collection. Within there, you can setup types of files to look for, location of the files, so forth and so on.

  • I have this script and variables

    ReadOnlyVariables - User::ExecDir and KellyMIS_CVSends

    ReadWright variables - User::FileExists

    And the following is the script to check the files(on the script tust )

    Imports System

    Imports System.Data

    Imports System.Math

    Imports System.IO

    Imports Microsoft.SqlServer.Dts.Runtime

    Public Class ScriptMain

    Public Sub Main()

    Dim fileLoc, fileName As String

    If Dts.Variables.Contains("User::ExecDir") = True AndAlso _

    Dts.Variables.Contains("User::KellyMIS_CVSends") = True Then

    fileLoc = CStr(Dts.Variables("User::ExecDir").Value)

    fileName = CStr(Dts.Variables.Item("User::KellyMIS_CVSends").Value)

    'System.Windows.Forms.MessageBox.Show(”FileDir:”+fileLoc+”FileName:” + fileName)

    If File.Exists(fileLoc + fileName) Then

    Dts.Variables.Item("User::FileExists").Value = True

    'System.Windows.Forms.MessageBox.Show(”File exists”)

    Else

    Dts.Variables.Item("User::FileExists").Value = False

    'System.Windows.Forms.MessageBox.Show(”File not exists”)

    End If

    Dts.TaskResult = Dts.Results.Success

    Else

    Dts.TaskResult = Dts.Results.Failure

    End If

    End Sub

    End Class

    This script was working the time I saved it but when I try to open it and run it the other day it is was not working.

  • I would step thru the script in VS and see if it is actually working correctly...although it does look good. Check to see what return value it's giving to the SSIS variable if any.

    You can also put an event handler in SSIS on Variable Value changed. I would set the Exists SSIS variable to false on initial load, run the script and see if the script is really changing the value to true or if the value from the script isn't getting passed back to SSIS.

  • Just some thoughts. Does the fileLoc contains a terminating slash? Otherwise try File.Exists(fileLoc + "\" + fileName). Does fileLoc contains a drive letter? Maybe something is wrong with your (network) drive mappings.

    Peter

  • Hi .I have tried adding "\" and it is still not working.I have palyed around the ssis parkage a lot but still not winning.I'll try to add an event handler and see the result.but I suspect that the problem might be coused by my computer settings or visual studio settings becouse it runs.

  • One thing to keep in mind with with VB to add a "\" to a string value you actually need to do "\\"

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply