How to se the dataset values to the Variable in Script TASK

  • Here is my code below

    int counter = 0;

    string line;

    System.IO.StreamReader reader =

    new System.IO.StreamReader(@"S:\Data\TestFile1.csv");

    System.Data.DataTable qlist = new System.Data.DataTable();

    System.Data.DataSet dslist = new System.Data.DataSet();

    while (!reader.EndOfStream)

    {

    var line1 = reader.ReadLine();

    string [] values = line1.Split(';');

    if (qlist.Columns.Count == 0)

    {

    foreach (string col in values)

    {

    DataColumn cols = new DataColumn(col.Trim(), typeof(string));

    qlist.Columns.Add(cols);

    }

    }

    else if (qlist.Columns.Count > 0)

    {

    var list = qlist.NewRow();

    list["Filename"] = values[0].ToString();

    list["Query"] = values[1].ToString();

    qlist.Rows.Add(list);

    }

    }

    dslist.Tables.Add(qlist);

    My output variable is object type

    DTS.variable["output"].values = dslist.Tables.Add(qlist);

    if add the dateset to the variable i get the error , is there any way we can dataset to the variable

    plz help me .

  • Why are you doing it like this and not using a flat file source?

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • my columns are dynamic so i bulid the columns dynamic and add the data , is it possible to set the data to the variable in the script task

  • i am trying with the flat file source , but i want to know how to set or assign the dataset values to the variable in

    script task

    i am trying with string its work fine but when i try with dataset its not ::crying:

  • SSIS does not really support dynamic columns. Do you have dynamic target columns too?

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • Hi

    I fixed the issue . the issue is due to the same variable is used in the project parmeter & variable , i have the changed the name and now i can assign the dataset values to the my output variable .

    Thank you

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply