I have a package that loads data to a DB from a file that is placed in a folder by a user. I have this part of the package working ok, but if the file is not there, then I want to be able to check this before running anything, and decided to use a script task, along with an email task for when the file is not found.
I've set this up with a new variable "FileExist" and created the script as per below:
Public Sub Main()
Dts.Variables("FileExist").Value = File.Exists(Dts.Variables("xlFileName").Value)
Dts.TaskResult = ScriptResults.Success
And the variables defined in the task like this:
The Variables in the package like this:
I keep getting this error thrown every time I run the package:
The type of the value (Boolean) being assigned to variable "User::FileExist" differs from the current variable type (String).
How can a boolean value being assigned to the variable, which is a Boolean type, cause it to fail?
I'd read that the scope of the variable (Package) might be the issue and to change it from package to the task, although the option to do this seems to be grayed out.
Could there be any other reasons this keeps failing? The strange thing is it's raising that error in the output but the actual package is not failing, but the email is not sending.