December 20, 2012 at 5:44 am
Hi,
i'm creating a ssis package to access a flat file.
i created a batch script to obtain the filename of the newest file in a folder.
this work fine, but when i want to give that filename to the connection manager by expression (i addes the UNC path with the variable who contains the filename)
at runtime i have the error : cannot open datafile...
who can help me?
December 27, 2012 at 4:36 am
Do you know how to use Script Tasks? I use them to check the values of my variables after the variables have been set.
Here are instructions in case you don't know how to use it.
Add Script Task right after the step that loads the variable value. (This is important as adding it before the variable is loaded will not give you the answer you need).
Choose Visual Basic as the script language in Script tab. (If you don't do this first, it will default to C# and you won't be able to change it short of deleting and recreating the task). C# is fine, BTW, if you know how to program it. This example uses a Visual Basic command.
In ReadOnlyVariables, put the variable names you want to check.
Click Edit Script.
Under Public Sub Main(), put the following code (do not put a single quote before it!):
MsgBox("This is the value of my variable named XYZ " + Dts.Variables("XYZ").Value.ToString)
XYZ, is the name of the variable you are reading. You can output multiple variables to a single message box command, but I prefer to do them one at a time so I can see them all.
When you run the package and it reaches this step, a little popup box will appear with your sentence and the value of the variable. If the sentence ends at "named XYZ" and nothing is after it, or if the popup message is blank, you've somehow got a NULL in your variable.
The package will stop until you click OK on this message box. Once you click OK, then it will continue on.
Usually you'll see an error in the path name at this point, or indications that the variable is not being loaded correctly. This is an essential troubleshooting tool for variables (though there may be others) that will help you nail down the problem.
December 28, 2012 at 2:09 am
This is an essential troubleshooting tool for variables (though there may be others) that will help you nail down the problem.
There are others - simply setting a pre-execute breakpoint on the task immediately following the one which sets the value of a variable will allow you to see the values of all variables' run-time values at that particular point.
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply