![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
hello i am trying to assign a value from a "recordset destination" column to a package variable with a ForEach Loop. The recordset column type is [DT_I8], based on an SQL Server query column which is a bigint type (DENSE_RANK() function return value) The package variable type is Int64 and the error I receive when I run the package is : Error: ForEach Variable Mapping number 1 to variable "User::rank" cannot be applied. Error: The type of the value being assigned to variable "User::rank" differs from the current variable type. Variables may not change type during execution. Variable types are strict, except for variables of type Object. I tried using the Object type for the package variable and it works for a small amount of records, but I am using a "script task" inside the ForEach Loop, and when the Loop gets to 30000 records, Visual Studio exits with a fatal application error. I think the type mapping is correct bigint = [DT_I8] = int64, so what could be the error cause ? thanks |
#3
| |||
| |||
|
|
Hello Paul, I have seen a number of people having problems with the Int64 datatype and have just tested and the same logic works if the variable and column are Int32 but fail when Int64. Personally I would do a convert to a string in the assignment query and then have a variable of type string. You could then convert the variable after the event Here is what I did in a script task to a string variable which was the assigned to variable in the ForEach loop (i64 is a string) Public Sub Main() Windows.Forms.MessageBox.Show(Dts.Variables("i64") .Value.ToString()) Dim i As Int64 = Convert.ToInt64(Dts.Variables("i64").Value) Windows.Forms.MessageBox.Show(i.ToString()) Dts.TaskResult = Dts.Results.Success End Sub Allan hello i am trying to assign a value from a "recordset destination" column to a package variable with a ForEach Loop. The recordset column type is [DT_I8], based on an SQL Server query column which is a bigint type (DENSE_RANK() function return value) The package variable type is Int64 and the error I receive when I run the package is : Error: ForEach Variable Mapping number 1 to variable "User::rank" cannot be applied. Error: The type of the value being assigned to variable "User::rank" differs from the current variable type. Variables may not change type during execution. Variable types are strict, except for variables of type Object. I tried using the Object type for the package variable and it works for a small amount of records, but I am using a "script task" inside the ForEach Loop, and when the Loop gets to 30000 records, Visual Studio exits with a fatal application error. I think the type mapping is correct bigint = [DT_I8] = int64, so what could be the error cause ? thanks |
![]() |
| Thread Tools | |
| Display Modes | |
| |