Domanda

I'm having some issues getting my data flow to do what I want it to.

I'm using an OLEDB Source that calls a stored procedure that uses a table variable to show me the data that I need to use. It looks like this:

ClientID    TimeStamp            IsStart
pic@psdfj   2013-08-28 14:22:59     1
bsd@fjskk   2013-08-28 14:43:21     1
pic@psdfj   2013-08-28 15:23:01     0
..and so on

I need to create two new columns, one with the timestamp, and the other with the IsStart column addded up. (I'm keeping track of when users are online and capturing the timestamp.) So I have a currently empty table in my SQL Server db called tblUserUsage, with the columns:

tblUserUsage (example of what the data would look like)
TimeStamp           NumberOfUsers
2013-08-28 14:22:59       1
2013-08-28 14:43:21       2
2013-08-28 15:23:01       1

I'm having issues getting my data flow to output to those columns. Right now I have the storedprocedure call connected to a Derived Column, then to a script. But that isn't working as it's not letting me output to the outputbuffer in the script when I create output columns. Just for clarification - the script will be in VB.NET

This is what my script looks like so far. I have a NumberOfUsers column added to the output. But I still have no Output0buffer Picture of Code

Anyone have any ideas?

È stato utile?

Soluzione

You only get an OutputBuffer generated in your code for asynchronous transforms (where the SynchronousInputID property of one or more outputs is set to zero). For synchronous transforms, your output columns will be in the InputBuffer.

Compare the MSDN articles Creating an Asynchronous Transformation with the Script Component and Creating a Synchronous Transformation with the Script Component.

Altri suggerimenti

Did you add a column to your output like this?

enter image description here

Then your output buffer would look something like this:

TableOutputBuffer.OutputColumnName = "hello";

Take a look a this sample I found here and maybe compare it to your code.. I usually write my scripts in c# so I can tell you if you're missing anything off the top of my head, but it might be worth a try.

    Public Class ScriptMain
Inherits UserComponent

Dim connMgr As IDTSConnectionManager100
Dim sqlConn As SqlConnection
Dim sqlReader As SqlDataReader

Public Overrides Sub AcquireConnections(ByVal Transaction As Object)

    connMgr = Me.Connections.MyADONETConnection
    sqlConn = CType(connMgr.AcquireConnection(Nothing), SqlConnection)

End Sub

Public Overrides Sub PreExecute()

    Dim cmd As New SqlCommand("SELECT AddressID, City, StateProvinceID FROM Person.Address", sqlConn)
    sqlReader = cmd.ExecuteReader

End Sub

Public Overrides Sub CreateNewOutputRows()

    Do While sqlReader.Read
        With MyAddressOutputBuffer
            .AddRow()
            .AddressID = sqlReader.GetInt32(0)
            .City = sqlReader.GetString(1)
        End With
    Loop

End Sub

Public Overrides Sub PostExecute()

    sqlReader.Close()

End Sub

Public Overrides Sub ReleaseConnections()

    connMgr.ReleaseConnection(sqlConn)

End Sub

End Class
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top