Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

SSIS read the first row's column from a flat flat into a variable

$
0
0
Public Class ScriptMain
    Inherits UserComponent

    Dim smpid As String
    Dim Prdt As String
    Dim rcnt As Int64



    Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
        With Row
            If Variables.RowCount = 0 Then

                smpid = Row.SampleId

                Prdt = Row.Product

                Variables.RowCount = Variables.RowCount + 1

            End If
        End With
    End Sub

    Public Overrides Sub PostExecute()



        Variables.SampleID = smpid.ToString

        Variables.Product = Prdt.ToString


    End Sub
End Class

Using the Vb script above I am expecting to read the first row from a flat file source and transferring the data into two variable using script component.

SQL server 2008.



Script task Custom Properties:

Script Task Input Columns:

I get the following errors one after the other:

"The collection of variables locked for read and write access is not available outside of PostExecute."

"Object reference not set to an instance of an object."

This is my flat file:

https://drive.google.com/file/d/0B418ObdiVnEIRnlsZFdwYTRfTFU/view?usp=sharing

I need help with fixing the vb script code. Thanks in advance.


svk




Viewing all articles
Browse latest Browse all 24688

Trending Articles