RhysW RhysW - 1 year ago 70
C# Question

Enumerating RecordSet in DataFlow Script Component as Data Source

This is an SSIS related issue

I have a variable that is set to type object. One Dataflow imports some filtered rows into a recordset and this recordset is stored in the object variable.

In a completely seperate dataflow i need to use that recordset as the source. So i created a script component and told it it would be a data source.

I set it up to have the three output columns that i need. My problem is, how do i get every row in the recordset to create a new row in the script component?

I passed in the recordset variable as a readonly variable, when i try to foreach the variable to get to each row i cannot do it because the variable doesn't define a get enumerator method.

Therefore i cant print each row out into those columns and cannot use my script component as a data source.

Has anyone else faced a similar situation? Am i doing something stupid or did you do it in another alternative way?

As a note i am using C# in the script and Visual studio 2008

Answer Source

So i looked around a bit and found a VB solution to my issue, i translated it over into C# and this now compiles and behaves as expected. The code i used was this:

    DataTable datatable = new DataTable();
    System.Data.OleDb.OleDbDataAdapter oAdapter = new System.Data.OleDb.OleDbDataAdapter();


    foreach (DataRow row in datatable.Rows)
        Output0Buffer.CoverAmount = Convert.ToInt32(row["XXXX"].ToString());

for any others who face a similar issue!

Thanks to all for the help

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download