ssis 2008, convert object to string on Expression

2019-09-07 00:02发布

问题:

im using SSIS for Sql server 2008.

Im declaring a path on a string variable on the Expression property:

"C:\\data\\Documents\\dt\\local." + @[User::Record] + ".xlsx"

The User::Record is of type Object.

I want to know how can I convert it from Object to String so I can assign it on the path.

Thanks..

回答1:

Expression is evaluated at compile time .So the variable User::Record is initialized as System.Object type .It does not contain any value .

Instead of declaring it as an expression ,try to use a script task to assign the path to the string variable .

Dts.Variables["User::Path"].Value =
"C:\\data\\Documents\\dt\\local." + Dts.Variables["User::Record"].Value.ToString() + ".xlsx"

I assume that before assigning the path to the string variable you are storing some value in User::Record variable . Else even after the above script task code ,your path variable will hold the value

C:\data\Documents\dt\local.System.Object.xlsx


标签: ssis