Friday, March 9, 2012

Mailing Result Set Rows

In the thread http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1071904&SiteID=1 mike.groh stated that you would define the result set as a data set variable through an execute sql task. He then pushed the variable out as a dataset type. (ds = CType(Dts.Variables("Email_CurrentDataset").Value, DataSet)

How would this type of object be declared as a user variable? Is it of type object? What is the logic behind converting a result set to a data set?

Specifically I am having problems with converting / casting the result set to a data set in that I am getting an error stating that it cannot convert the com object to a data.dataset class...

Imports ADODB

Imports System

Imports System.Xml

Imports System.Collections

Imports System.Data

Imports System.Math

Imports Microsoft.SqlServer.Dts.Runtime

Imports Microsoft.SqlServer.Dts

Imports Microsoft.SqlServer.Dts.DtsClient

PublicClass ScriptMain

PublicSub Main()

Dim ds As DataSet

Dim dr As DataRow

Dim str AsString

Dim dtm AsString

Dim s AsString

Try

ds = CType(Dts.Variables("resultSet").Value, DataSet) ' <-- Error on converting

Dts.TaskResult = Dts.Results.Success

Catch ex As Exception

Dts.TaskResult = Dts.Results.Failure

EndTry

Here's the code to convert an ADO resultset to an ADO.NET dataset.

Code Snippet

Dim oledbAdapter As New OleDb.OleDbDataAdapter
Dim dataTable As New System.Data.DataTable

oledbAdapter.Fill(dataTable, Me.Variables.resultset)

No comments:

Post a Comment