I have a package which first uses a sql task to place a full data set (2 columns of data) into an ssis object variable, then I have a foreach loop that loops through some files, parsing data and other stuff in a c# script task. In this script task I pull in the sql data set variable initially retrieved (outside the loop), referencing it as read only variable on the script task, and use the data as I compare records within the script task.
The problem I am having is that on the first file the script task runs on within the foreach loop, it works great, but after than the ssis variable is blank. I can't seem to figure out why it is blank, the only thing I do with the variable is pull it into a datatable:
DataTable dt = new DataTable();
OleDataAdapter oleDa = new OleDataAdapter();
oleDa.Fill(dt, Dts.Variables["User::MyVariable"].Value);
I used a messagebox to check the variable after these lines, and the User::MyVariable is empty afterwards. How do I prevent that from happening? I need to use it more.
EDIT: I read that using Fill will empty the data set on the variable, and have seen that I need to write my datatable back to the ssis variable, however I then get an error stating object is not an ADODB.RecordSet or an ADODB.Record.