I used the code below to fill a data table -
OleDbDataAdapter oleDA = new OleDbDataAdapter();
DataTable dt = new DataTable();
oleDA.Fill(dt, Dts.Variables[
In a script task, I created a datatable called DtUsers, created columns in the datatable, added rows and assigned values to the row cells. I then stored this datatable in an object variable called activeDirectoryUsers:
Dts.Variables["User::activeDirectoryUsers"].Value = DtUsers;
I then created a Data Flow and added a Source Script Component. I tried to use Fill() and received the same error as the OP.
OleDbDataAdapter da = new OleDbDataAdapter();
DataTable dt = new DataTable();
da.Fill(dt, Variables.activeDirectoryUsers); //error here
Object is not an ADODB.RecordSet or an ADODB.Record
The solution for me was twofold:
Add the DtUsers datatable to a DataSet and then store the DataSet in the object variable.
DataSet ds = new DataSet();
ds.Tables.Add(DtUsers);
Dts.Variables["User::activeDirectoryUsers"].Value = ds;
In the Source Script Component, create a new DataSet and cast the object variable to type DataSet, and assign it to the DataSet:
DataSet ds = (DataSet)Variables.activeDirectoryUsers;
if (ds == null || ds.Tables.Count == 0) return;
DataTable dt = ds.Tables[0];
//do stuff with dt...
This article led me to this solution.