SSIS - How to access a RecordSet variable inside a Script Task

GordyII picture GordyII · Apr 8, 2010 · Viewed 61.9k times · Source

How do you access a RecordSet variable inside a Script Task?

Answer

Tequila picture Tequila · Dec 31, 2012

Listed below is the code I used to load a datatable in a C# script task from a recordset or resultset variable. "User::transactionalRepDBs" is a SSIS variable of Object (System.Object) that was loaded through a "Full result set" from a execute SQL task script. This link assisted me.

using System.Data.OleDb;

DataTable dt= new DataTable();
OleDbDataAdapter adapter = new OleDbDataAdapter();
adapter.Fill(dt, Dts.Variables["User::transactionalRepDBs"].Value);

foreach (DataRow row in dt.Rows)
{
   //insert what you want to do here
}