PipelineBuffer.DirectErrorRow Method
Sends a PipelineBuffer row to an IDTSOutput90 whose IsErrorOut property is true.
命名空间: Microsoft.SqlServer.Dts.Pipeline
程序集: Microsoft.SqlServer.PipelineHost (in microsoft.sqlserver.pipelinehost.dll)
语法
声明
Public Sub DirectErrorRow ( _
outputID As Integer, _
errorCode As Integer, _
errorColumn As Integer _
)
public void DirectErrorRow (
int outputID,
int errorCode,
int errorColumn
)
public:
void DirectErrorRow (
int outputID,
int errorCode,
int errorColumn
)
public void DirectErrorRow (
int outputID,
int errorCode,
int errorColumn
)
public function DirectErrorRow (
outputID : int,
errorCode : int,
errorColumn : int
)
参数
- outputID
The ID of the error IDTSOutput90 to send the PipelineBuffer row.
- errorCode
The error number that occurred while processing the row.
- errorColumn
The index of the PipelineBuffer column that caused the error.
备注
This method is used by data flow components that have IDTSOutput90 objects with the IsErrorOut property set to true. It is called by the component when it encounters an error processing a buffer row, and when RD_RedirectRow is specified on the input, output, or column.
示例
The following code example demonstrates how to direct a row in a buffer to a synchronous error output by using the DirectErrorRow method.
public override void ProcessInput(int inputID, PipelineBuffer buffer)
{
if (!buffer.EndOfRowset)
{
IDTSInput90 input = ComponentMetaData.InputCollection.GetObjectByID(inputID);
/// This code sample assumes the component has 2 outputs, one the default,
/// the other the error output. If the errorOutputIndex returned from GetErrorOutputInfo
/// is 0, then the default output is the second output in the collection.
int defaultOutputID = -1;
int errorOutputID = -1;
int errorOutputIndex = -1;
GetErrorOutputInfo(ref errorOutputID,ref errorOutputIndex);
if (errorOutputIndex == 0)
defaultOutputID = ComponentMetaData.OutputCollection[1].ID;
else
defaultOutputID = ComponentMetaData.OutputCollection[0].ID;
while (buffer.NextRow())
{
try
{
/// TODO: Implement code to process the columns in the buffer row.
/// Ideally, your code should detect potential exceptions prior to them occurring, rather
/// than having a generic try/catch block such as this.
/// However, since the error or truncation implementation is specific to each component
/// this sample focuses on actually directing the row, and not a single error or truncation.
/// Unless an exception occurs, direct the row to the default
buffer.DirectRow(defaultOutputID);
}
catch
{
/// Yes. Has the user specified to redirect the row?
if (input.ErrorRowDisposition == DTSRowDisposition.RD_RedirectRow)
{
/// Yes, direct the row to the error output.
/// TODO: Add code to include the errorColumnIndex
buffer.DirectErrorRow(errorOutputID, 0, errorColumnIndex);
}
else if (input.ErrorRowDisposition == DTSRowDisposition.RD_FailComponent || input.ErrorRowDisposition == DTSRowDisposition.RD_NotUsed)
{
/// No, the user specified to fail the component, or the error row disposition was not set.
throw new Exception("An error occurred, and the DTSRowDisposition is either not set, or is set to fail component.");
}
else
{
/// No, the user specified to ignore the failure so
/// direct the row to the default output.
buffer.DirectRow(defaultOutputID);
}
}
}
}
}
Public Overrides Sub ProcessInput(ByVal inputID As Integer, ByVal buffer As PipelineBuffer)
If Not buffer.EndOfRowset Then
Dim input As IDTSInput90 = ComponentMetaData.InputCollection.GetObjectByID(inputID)
Dim defaultOutputID As Integer = -1
Dim errorOutputID As Integer = -1
Dim errorOutputIndex As Integer = -1
GetErrorOutputInfo(errorOutputID, errorOutputIndex)
If errorOutputIndex = 0 Then
defaultOutputID = ComponentMetaData.OutputCollection(1).ID
Else
defaultOutputID = ComponentMetaData.OutputCollection(0).ID
End If
While buffer.NextRow
Try
buffer.DirectRow(defaultOutputID)
Catch
If input.ErrorRowDisposition = DTSRowDisposition.RD_RedirectRow Then
buffer.DirectErrorRow(errorOutputID, 0, errorColumnIndex)
Else
If input.ErrorRowDisposition = DTSRowDisposition.RD_FailComponent OrElse input.ErrorRowDisposition = DTSRowDisposition.RD_NotUsed Then
Throw New Exception("An error occurred, and the DTSRowDisposition is either not set, or is set to fail component.")
Else
buffer.DirectRow(defaultOutputID)
End If
End If
End Try
End While
End If
End Sub
线程安全
Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
平台
开发平台
有关支持的平台列表,请参阅安装 SQL Server 2005 的硬件和软件要求。
目标平台
有关支持的平台列表,请参阅安装 SQL Server 2005 的硬件和软件要求。
请参阅
参考
PipelineBuffer Class
PipelineBuffer Members
Microsoft.SqlServer.Dts.Pipeline Namespace