[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

VB.net Object Variable to a string

Posted on 2013-05-20
2
Medium Priority
?
743 Views
Last Modified: 2016-02-11
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
'Imports System.Net
'Imports System.Net.Mail
Imports System.Windows.Forms
Imports System.Xml
Imports System.Data.OleDb


<System.AddIn.AddIn("ScriptMain", Version:="1.0", Publisher:="", Description:="")> _
<System.CLSCompliantAttribute(False)> _
Partial Public Class ScriptMain
	Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase

	Enum ScriptResults
		Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success
		Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
	End Enum
	

    Public Sub Main()
        Dts.TaskResult = CInt(ScriptResults.Success)
        Dim oleDA As New OleDbDataAdapter()
        Dim dt As New DataTable()
        Dim col As DataColumn = Nothing
        Dim row As DataRow = Nothing
        Dim strMsg As String = Nothing
        'Dim strMessage1 As String = Nothing


        oleDA.Fill(dt, Dts.Variables("listDates").Value)

        For Each row_ As DataRow In dt.Rows
            row = row_
            For Each col_ As DataColumn In dt.Columns
                col = col_
                strMsg = strMsg & col.ColumnName & ": " & row(col.Ordinal).ToString() & Environment.NewLine
            Next
            MessageBox.Show(strMsg)
            strMsg = ""
            'strMessage1 = strMsg
        Next
        'strMessage1 = strMsg

        Dts.TaskResult = CInt(ScriptResults.Success)

    End Sub

End Class

Open in new window

Hello Experts,

I am trying to write VB script in "SSIS Script Task Component to capture the data from an Object Variable and assign it to a string variable.

I have this below code (Source: Google) which loops for every record and displays it in a mesage box. Instead of this, I need your help in modifying the below code to get all the data from the object variable to a string variable.

Obejct Variable will get the data from a query which results in to 1 column and mutliple rows.



Please help!!!

Thanks in advance!!
0
Comment
Question by:ravichand-sql
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Accepted Solution

by:
ravichand-sql earned 0 total points
ID: 39182541
Got the fix!!

Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
'Imports System.Net
'Imports System.Net.Mail
Imports System.Windows.Forms
Imports System.Xml
Imports System.Data.OleDb


<System.AddIn.AddIn("ScriptMain", Version:="1.0", Publisher:="", Description:="")> _
<System.CLSCompliantAttribute(False)> _
Partial Public Class ScriptMain
	Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase

	Enum ScriptResults
		Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success
		Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
	End Enum
	

    Public Sub Main()
        Dts.TaskResult = CInt(ScriptResults.Success)
        Dim oleDA As New OleDbDataAdapter()
        Dim dt As New DataTable()
        Dim col As DataColumn = Nothing
        Dim row As DataRow = Nothing
        Dim strMsg As String = Nothing
        'Dim strMessage1 As String = Nothing


        oleDA.Fill(dt, Dts.Variables("listDates").Value)

        For Each row_ As DataRow In dt.Rows
            row = row_
            For Each col_ As DataColumn In dt.Columns
                col = col_
                strMsg = strMsg & col.ColumnName & ": " & row(col.Ordinal).ToString() & Environment.NewLine
            Next
            'MessageBox.Show(strMsg)
            'strMsg = ""
            'strMessage1 = strMsg
        Next
        Dts.Variables("User::strMessage1").Value = strMsg

        Dts.TaskResult = CInt(ScriptResults.Success)

    End Sub

End Class

Open in new window


Thanks!
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A couple of weeks ago, my client requested me to implement a SSIS package that allows them to download their files from a FTP server and archives them. Microsoft SSIS is the powerful tool which allows us to proceed multiple files at same time even w…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question