Hi,
I have been trying to add a Script component to my SSIS dataflow, but I am getting an "Object reference not set to an instance of an object" when I try to set the value of the Output Columns.
I have tried stripping down my code to a really basic example and I still get the issue. What I am doing is as follows.
I have an OLE DB Source which just selects data from a table, and that goes straight into my script component. The source just produces 1 row. I have passed through both columns they are both set to read only;
![]()
Then I am adding 1 output column with a datatype of int. Output properties are;
![]()
The column properties are;
![]()
I have also added one connection manager which I am not doing anything with in the script currently. Script Component code is all default stuff, all I have added is one line to set my Column1 output column to 1. The main.cs class is as follows.
public class ScriptMain : UserComponent
{
/// <summary>
/// This method is called once, before rows begin to be processed in the data flow.
///
/// You can remove this method if you don't need to do anything here.
/// </summary>
public override void PreExecute()
{
base.PreExecute();
/*
* Add your code here
*/
}
/// <summary>
/// This method is called after all the rows have passed through this component.
///
/// You can delete this method if you don't need to do anything here.
/// </summary>
public override void PostExecute()
{
base.PostExecute();
/*
* Add your code here
*/
}
/// <summary>
/// This method is called once for every row that passes through the component from Input0.
///
/// Example of reading a value from a column in the the row:
/// string zipCode = Row.ZipCode
///
/// Example of writing a value to a column in the row:
/// Row.ZipCode = zipCode
/// </summary>
/// <param name="Row">The row that is currently passing through the component</param>
public override void Input0_ProcessInputRow(Input0Buffer Row)
{
/*
* Add your code here
*/
Row.Column1 = 1;
}
When I run the code I get the following exception (debugging shows it is thrown when trying to set Row.Column1 = 1;
Object reference not set to an instance of an object.
at Microsoft.SqlServer.Dts.Pipeline.PipelineBuffer.set_Item(Int32 columnIndex, Object value)
at ScriptMain.Input0_ProcessInputRow(Input0Buffer Row)
at UserComponent.Input0_ProcessInput(Input0Buffer Buffer)
at UserComponent.ProcessInput(Int32 InputID, String InputName, PipelineBuffer Buffer, OutputNameMap OutputMap)
at Microsoft.SqlServer.Dts.Pipeline.ScriptComponent.ProcessInput(Int32 InputID, PipelineBuffer buffer)
at Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost.ProcessInput(Int32 inputID, PipelineBuffer buffer)
I can't work out why it isn't working, I followed several different examples on how to write a script component, and what I am doing looks fine (?), but I always get the same issue. I do need the script component to do the transformation I am working on
(more complex than just setting a column to 1) but I can't get it working for the simplest case.
I am really hoping someone is going to point out an obvious issue in something I have done :)
I am using Visual Studio 2015, latest SQL Server Data Tools build (14.0.60629.0) and SQL Server 2012.
Let me know if anything else is required to help me,
cheers,
Rob