February 26, 2008 at 12:00 pm
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
February 26, 2008 at 1:25 pm
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.
February 27, 2008 at 1:27 am
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.
February 29, 2008 at 5:53 pm
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.
March 1, 2008 at 4:22 am
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
March 3, 2008 at 3:15 am
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.
March 3, 2008 at 10:17 am
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