tags:

views:

102

answers:

1

What I am trying to accomplish is using this script task to continually insert into a generated RecordSet I know how to access it in the script however I do not know how to update it after my changes to the DataTable have been made.

Code is Below:

    Dim EmailsToSend As New OleDb.OleDbDataAdapter
    Dim EmailsToSendDt As New DataTable("EmailsToSend")
    Dim CurrentEmailsToSend As New DataTable
    Dim EmailsToSendRow As DataRow

    EmailsToSendDt.Columns.Add("Id", System.Type.GetType("System.Integer"))
    EmailsToSendDt.Columns.Add("EmailAddress", System.Type.GetType("System.String"))
    EmailsToSendDt.Columns.Add("EmailMessage", System.Type.GetType("System.String"))

    EmailsToSendRow = EmailsToSendDt.NewRow()
    EmailsToSendRow.Item("Id") = Id
    EmailsToSendRow.Item("EmailAddress") = Email
    EmailsToSendRow.Item("EmailMessage") = EmailMessage.ToString

    EmailsToSend.Fill(CurrentEmailsToSend, Dts.Variables("EmailsToSend").Value)
    EmailsToSendDt.Merge(CurrentEmailsToSend, True)

Basically my goal is to create a single row in a new data table. Get the current record set, merge the results so I have my result DataTable. Now I just need to update the ReadWriteVariable for my script. Do not know if I have to do anything special or if I can just assign it directly to the DataTable I.E. Dts.Variables("EmailsToSend").Value = EmailsToSendDt

Thanks for the help in advanced.

+1  A: 

Here is a previous answer of mine that addresses your problem: http://stackoverflow.com/questions/2881140/store-dataset-to-dts-variable/2881714#2881714

The short answer is that you can do it just like you mentioned above, by setting the object typed variable's value to the data table variable in your script.

William Todd Salzman
That is exactly what I ended up having to do. Thank you for the help.
Zambouras

related questions