Could anyone please tell me about how to set values of c# script SSIS task's variable to package variable? Example: we have table with one column. In sql task we get it to the full result set as object variable. Then we pass this package variable to script task. After this we do some data manipulation:
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using System.Data.OleDb;
namespace ST_81cd1d2d439843b086cf3eb4d3b22d66.csproj
{
[System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
{
#region VSTA generated code
enum ScriptResults
{
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
};
#endregion
public void Main()
{
OleDbDataAdapter A = new OleDbDataAdapter();
DataTable dt = new DataTable();
A.Fill(dt, Dts.Variables["User::i"].Value);
int i;
foreach (DataRow row in dt.Rows)
{
object[] array = row.ItemArray;
i = (int)array[0];
i += 1;
}
//Dts.TaskResult = (int)ScriptResults.Success;
}
}
}
How to move out variables of script task to another sql task for insert data to MS SQL target table? I mean should it be new object package variable or new variables for all column of our first object varialbe? How to correctly move full DataSet or all variables' values from c# script task to sql task?
Thank you a lot.
Is there any features for converting object to DataTable?
public void Main()
{
OleDbDataAdapter A = new OleDbDataAdapter();
DataTable dt = new DataTable();
A.Fill(dt, Dts.Variables["User::i"].Value);
A = (DataTable)Dts.Variables["User::o"];
int i;
foreach (DataRow row in dt.Rows)
{
object[] array = row.ItemArray;
i = (int)array[0];
i += 1;
}
//Dts.TaskResult = (int)ScriptResults.Success;
}