Reading project parameters in Script Task

Metaphor picture Metaphor · Dec 5, 2013 · Viewed 19.3k times · Source

This is what I'm trying to do in a script task:

long lngMaxRowsToPull = Convert.ToInt64(Dts.Variables["Project::MaxRowsPerPull"].Value);

I get an error message that the variable does not exist.

Yet Its defined as a ReadOnlyVariable to the script and it does exist as a project parameter.

Its defined as a ReadOnlyVariable to the script

And it does exist as a project parameter

Answer

billinkc picture billinkc · Dec 5, 2013

So close. ;)

Your code is trying to access a variable/parameter named Project::MaxRowsPerPull

In fact, the $ is significant so you need to reference $Project::MaxRowsPerPull

Also note that you have the data type for the parameter as Int32 but are then pushing it into Int64. You can always put a smaller type into a larger container but if you tried to fill the parameter with too large a value your package will asplode.