My value for a Variable I load from an SSIS Task Resultset goes to -1

I have a simple Select Statement that returns a single row. I am trying to read that value into a Package Level Variable and then use that variable in the next step.

Each time I run the package, I get the value -1 returned. Details of what I am trying to do is as follows:
SQL Statement: Select (Max(LoadNumber) + 1) As LoadNumber From TableName

Variable Name: User::LoadNumber, Datatype Int32

Execute SQL Task Details:
- ResultSet: SingleRow
- ConnectionType: OLEDB
On the Result Set Tab:
- ResultName: LoadNumber
- Variable Name: User::LoadNumber

I have a Script Task after this task to show a Messagebox with the value of the Variable and it shows -1

When I run the statement in a Query window, it shows the correct value.

Does anyone know why I could be getting -1? Seems like some type of returncode to me but I can't find from what?
Who is Participating?
QCentricConnect With a Mentor Author Commented:
I decided to change the return value from Int32 to String and I can now read the value fine.
What is the SingleRow Result Set datatype set to? LONG?
QCentricAuthor Commented:
I can't find the property for the SingleRow Result Set dataypte.

The ForcedExecutionValueType is Int32
The Value returned in the Select Statement is Int
The User Variable is Int32
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.