1

I have two script tasks in my SSIS package. The first one saves a string array as a package variable:

// In 1st script task:
String[] astrCustNames = new String[cust_count];

/* ...
 * Some code to add strings to array ...
 */

// Add array to a package variable
Dts.Variables["CustomerNames"].Value = astrCustNames;

The second task should then extract the strings from the variable. In the past, I've done this with a table variable. This won't work for the string array:

// In 2nd script task:
OleDbDataAdapter ole_da = new OleDbDataAdapter();
// Fill the customer names data table
DataTable dtCustNames = new DataTable();
ole_da.Fill(dtCustNames, Dts.Variables["User::CustomerNames"].Value);

The call that fills the data adapter will result in the error "Object is not an ADODB.RecordSet or an ADODB.Record."

The .dtsx package lists the data type as DTS:DataType="13"

The data type of the variable as it is defined in the package is "Object":

// Returns type "Object":
TypeCode cur_type = Dts.Variables["User::CustomerNames"].DataType;

I've been searching for an example of extracting strings stored in an array in an SSIS variable, but have found none.

1 Answer 1

1

Okay, it turns out that this couldn't be simpler.

Just cast the value to a string array:

String[] astrCustNames = (String[])Dts.Variables["User::CustomerNames"].Value;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.