bonjour a tous.
je suis en train de développer sous SSIS. et j'ai besoin de faire un script en C# et je suis nul a ca.
j'ai fais un code mais ca plante.
libelle de l'erreur :
There is no current row in the buffer. A row may need to be added using the AddRow method.
ci joint mon code.
merci d'avance
/* Microsoft SQL Server Integration Services Script Component
* Write scripts using Microsoft Visual C# 2008.
* ScriptMain is the entry point class of the script.*/
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
{
ulong cumul_reg = 0 ;
ulong cumul_ouv = 0 ;
string lib_gti_retain = "init" ;
ulong tx_accept_cum =0 ;
public override void PreExecute()
{
base.PreExecute();
/*
Add your code here for preprocessing or remove if not needed
*/
}
public override void PostExecute()
{
base.PostExecute();
/*
Add your code here for postprocessing or remove if not needed
You can set read/write variables here, for example:
Variables.MyIntVar = 100
*/
}
public override void Input0_ProcessInputRow(Input0Buffer Row)
{
if (lib_gti_retain == "init")
{
lib_gti_retain = Row.LibelleGarantie;
}
if (lib_gti_retain == Row.LibelleGarantie)
{
cumul_reg = Row.cptreg + cumul_reg ;
cumul_ouv = Row.CompteurOuverture + cumul_ouv ;
tx_accept_cum = (cumul_reg / cumul_ouv) * 100;
/* MyOutputBuffer.tx_accept_cum = tx_accept_cum ; */
MyOutputBuffer.LibelleGarantie = Row.LibelleGarantie;
}
else
{ lib_gti_retain = Row.LibelleGarantie;
cumul_reg = 0;
cumul_ouv = 0;
cumul_reg = Row.cptreg + cumul_reg;
cumul_ouv = Row.CompteurOuverture + cumul_ouv;
tx_accept_cum = (cumul_reg / cumul_ouv) * 100;
/* MyOutputBuffer.tx_accept_cum = tx_accept_cum; */
MyOutputBuffer.LibelleGarantie = Row.LibelleGarantie;
}
MyOutputBuffer.AddRow();
}
public override void Input0_ProcessInput(Input0Buffer Buffer)
{
while (Buffer.NextRow())
{
Input0_ProcessInputRow(Buffer);
}
if (Buffer.EndOfRowset())
{
MyOutputBuffer.SetEndOfRowset();
}
}
public override void CreateNewOutputRows()
{
/*
Add rows by calling the AddRow method on the member variable named "<Output Name>Buffer".
For example, call MyOutputBuffer.AddRow() if your output was named "MyOutput".
*/
}
}
Partager