February 25, 2010 at 4:43 pm
i have a package where i pass accountnumber to an execute sql task inside a for each loop and store the result in a package level variable.
i am passing the accountnumber as input parameter to execute sql task
i want to know how to extract the values from the resultset variable?
please suggest
February 25, 2010 at 4:55 pm
Since the values of a result set are normally stored in a object they cannot be retrieved .. Alternative is to use a script component and convert this object variable to string and assign this to a string variable.. Is that what you are looking for?
dim s as string
s= Dts.Variables("objvariable").Value.ToString
Stringvariable = s
February 25, 2010 at 5:17 pm
You can use a script task to do it, here is the basis for the code:
Code to walk through OLEDB data..
Dim _oOledbAdapter As New OleDb.OleDbDataAdapter
Dim _oDataTable As New System.Data.DataTable
Dim _oDataRow As Data.DataRow
_oOledbAdapter.Fill(_oDataTable, Dts.Variables("ResultSetVariable").Value)
For Each _oDataRow In _oDataTable.Rows
'Walk through fields for this row here using _oDataRow.Item(1).ToString
Next
CEWII
February 26, 2010 at 1:18 pm
keywestfl9 (2/25/2010)
i have a package where i pass accountnumber to an execute sql task inside a for each loop and store the result in a package level variable.i am passing the accountnumber as input parameter to execute sql task
i want to know how to extract the values from the resultset variable?
please suggest
What does the resultset look like: 1 value, 1 record or multiple records. In case of 1 or more records, what are the columns?
What is your loop doing?
February 26, 2010 at 2:15 pm
this package contains two execute sql task..
1. to start with i find out the duplicate records and pass to the other execute sql task which is in the for each loop
second execute sql task which is in for reach loop will extract data pertaining to duplicate records by the sql statement i have in the sql task and the resultset i store it in a variable (user::finalresult)
i want to retrieve the values of the variable and create a txt file or excel and attach it in a email.
February 26, 2010 at 2:22 pm
I keep getting this error ..i tried this option mentioned
dim s as string
s= Dts.Variables("objvariable").Value.ToString
Stringvariable = s
The element cannot be found in a collection. This error happens when you try to retrieve an element
from a collection on a container during execution of the package and the element is not there.
February 26, 2010 at 2:37 pm
Do you have "objvariable" in the readonly or readwrite variables?
CEWII
February 26, 2010 at 2:50 pm
you need to add "objvariable" as readonly and the other variable as writeonly and then use them in the script task... You can add them in the general tab of script component/task
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply