none
Output Buffer not populating. RRS feed

  • Question

  • I am trying to transform the existing table to different table. I am getting multiple rows as string and  want to store it under one row using comma.

    I have creating a data flow task and added a script component that will take the string and convert to blob data. But I get an error for output column which is nvarchar(max) in SQL Server

     using System;
     using System.Data;
     using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
     using Microsoft.SqlServer.Dts.Runtime.Wrapper;
    
    [Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
     public class ScriptMain : UserComponent
    {
            private string ComputerName;
            private string TimeofLastScanAttempt;
            private string CopyofRPMCustom;
            Byte buffer;
            private bool FirstRow = true;
    
    
           public override void Input0_ProcessInputRow(Input0Buffer Row)
          {
    
                 if ((Row.ComputerName == ComputerName && 
                 Row.TimeofLastScanAttempt == TimeofLastScanAttempt) || 
                FirstRow)
         {
                CopyofRPMCustom += (Row.CopyofRPMCustom_IsNull? "," : 
                Row.CopyofRPMCustom);
                ComputerName = Row.ComputerName;
                TimeofLastScanAttempt = Row.TimeofLastScanAttempt;
                FirstRow = false;
          }
           else
          {
               Output0Buffer.AddRow();
               Output0Buffer.TimeofLastScanAttempt = TimeofLastScanAttempt;
               Output0Buffer.ComputerName = ComputerName;
    
               Output0Buffer.RPM.AddBlobData(
               System.Text.Encoding.Unicode.GetBytes(CopyofRPMCustom ?? ""));
    
                CopyofRPMCustom += (Row.CopyofRPMCustom_IsNull ? "," : 
               Row.CopyofRPMCustom);
                ComputerName = Row.ComputerName;
                TimeofLastScanAttempt = Row.TimeofLastScanAttempt;
    
              }
           }
    
    
          public override void FinishOutputs()
        {
    
    
    
             Output0Buffer.AddRow();
             Output0Buffer.TimeofLastScanAttempt = TimeofLastScanAttempt;
            Output0Buffer.ComputerName = ComputerName;
    
             Output0Buffer.RPM.AddBlobData(
             System.Text.Encoding.Unicode.GetBytes(CopyofRPMCustom ?? ""));
            base.FinishOutputs();
    
        }

    When I debug this code I get the error- 'Output0Buffer.RPM' threw an exception of type 'Microsoft.SqlServer.Dts.Pipeline.NoCurrentRowException' 'Output0Buffer.RPM_IsNull' threw an exception of type 'Microsoft.SqlServer.Dts.Pipeline.NoCurrentRowException'

    The tasks run  successfully but the RPM column is empty. Everything else is populated.

    Friday, August 16, 2019 8:40 PM

All replies