Multiply InputDataBuffer for resulting file with VB.net
Good day, I'm using Script Transformation Editor (VB.net) for creating data for file. Created data should contain multiplied data for resulting file, so I use for this dataset. But It doesn't work. Can you help me? Imports System Imports System.Data Imports System.Math Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper Imports Microsoft.SqlServer.Dts.Runtime.Wrapper <Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute> _ <CLSCompliant(False)> _ Public Class ScriptMain Inherits UserComponent Public ds As New DataSet Public Sub createDataset() Dim dt As New DataTable("Nodes") dt.Columns.Add("Node", String.Empty.GetType()) ds.Tables.Add(dt) End Sub Public Overrides Sub PreExecute() MyBase.PreExecute() createDataset() End Sub Public Overrides Sub PostExecute() MyBase.PostExecute() End Sub Public Overrides Sub InputData_ProcessInputRow(ByVal Row As InputDataBuffer) Dim dr As DataRow = ds.Tables("Nodes").NewRow() dr("Node") = Row.Goal ds.Tables("Nodes").Rows.Add(dr) End Sub Public Overrides Sub CreateNewOutputRows() Dim myRow As DataRow Me.OutputDataBuffer.AddRow() Me.OutputDataBuffer.ResultNode = "[Version]" Me.OutputDataBuffer.AddRow() Me.OutputDataBuffer.ResultNode = """Project_by_VB""" Me.OutputDataBuffer.AddRow() Me.OutputDataBuffer.ResultNode = "[Hierarchy]" Me.OutputDataBuffer.AddRow() Me.OutputDataBuffer.ResultNode = """Project""" & "#" & """Projects""" Me.OutputDataBuffer.AddRow() Me.OutputDataBuffer.ResultNode = "[Node]" For Each myRow In ds.Tables("Nodes").Rows Me.OutputDataBuffer.AddRow() MsgBox(myRow.Item("Node").ToString()) Me.OutputDataBuffer.ResultNode = myRow.Item("Node").ToString() Next End Sub End Class
January 26th, 2011 8:55am

Please clarify what you by "multiplied data". Can you also provide sample input and desired output for demonstration purposes?Adam Tappis. (MCSD VB6 & .NET, MCDBA SQL 2000)
Free Windows Admin Tool Kit Click here and download it now
January 26th, 2011 9:04am

My input: Node 1 Node 2 Node 3 Desired output: [Version] test_version [Hierarchy] test_hierarchy [Nodes] Project - Node 1 Project - Node 2 Project - Node 3 [Relationship] TopNode - Node 1 TopNode - Node 2 TopNode - Node 3 Node 1, Node 2, Node 3 multiplied 2 times (what I want)
January 26th, 2011 9:09am

It would also help if you explained what you mean by "it doesn't work". What output are you seeing? Just by scanning your code I see that you only have one For Each loop to output the nodes. You probably need another one for the "Relationships" part of the output. As a general comment, if you seek help on forums please make sure you give as much information aspossible in your initial question rather than just "it doesn't work" or "it throws an error". Put yourself in the position of a person trying to help and try to anticipate the questions they might ask and provide the answers up front. That will get you to an answer a lot faster.Adam Tappis. (MCSD VB6 & .NET, MCDBA SQL 2000)
Free Windows Admin Tool Kit Click here and download it now
January 26th, 2011 10:04am

In result I get text file that doesn't contain anything after [Nodes] (however there must be Nodes - Node 1, Node 2, Node 3) Thanks for remark.
January 26th, 2011 10:17am

I can't see anything in your code that jumps out as a problem. You need to try and debug. I suspect that your message box doesn't show up because (as far as I can remember) they don't show in script transforms in the data flow tab. You can try adding a data viewer to the output arrow coming from your script transform. I suggest you do this for both the data flows coming into this stript transform and the on we coming out and validate that that the correct set of data is flowing in and the incorrect is flowing out. If you can prove this then it's the code that's the problem.Adam Tappis. (MCSD VB6 & .NET, MCDBA SQL 2000)
Free Windows Admin Tool Kit Click here and download it now
January 26th, 2011 10:36am

The problem with the code is that you're using the CreateNewOutputRows method. This method is called BEFORE ProcessInputRow in an asynchronous script. Therefore, at that time, there are no rows in your internal dataset. What you need to do is move the code you have in CreateNewOutputRows into an override of the ProcessInput method. But you will have to make sure that you execute the base method as the first call of that override (otherwise your ProcessInputRow method won't get called). Then you can see if you've received ALL of the rows by checking the EndOfRowset() method on the input buffer. If this returns true, then you can execute your output code. Talk to me now on
February 2nd, 2011 12:16pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics