Assume that in an SSIS package you have an Execute SQL Task that returns a Resultset/Recordset into a variable called objRecordset
(e.g. select * from Orders) ...
and now you want to access that data in a ScriptTask to perform some row by row operations.
Here is the code snippet on how you can do it.
(Plagerized/modified from Nayan Patel's
post
)
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Imports System.Xml
Imports System.Data.OleDb
Public Class ScriptMain
Public Sub Main()
Dim oleDA As New OleDbDataAdapter
Dim dt As New DataTable
Dim col As DataColumn
Dim row As DataRow
Dim sMsg As String
oleDA.Fill(dt, Dts.Variables("objRecordset").Value)
For Each row In dt.Rows
For Each col In dt.Columns
sMsg = sMsg & col.ColumnName & ": " & row(col.Ordinal).ToString & vbCrLf
Next
MsgBox(sMsg)
sMsg = ""
Next
Dts.TaskResult = Dts.Results.Success
End Sub
End Class