SqlPipe.SendResultsEnd 方法

定义

标记结果集的结尾,并将 SqlPipe 实例返回到初始状态。

public:
 void SendResultsEnd();
public void SendResultsEnd ();
member this.SendResultsEnd : unit -> unit
Public Sub SendResultsEnd ()

例外

示例

以下示例创建一个新的 SqlDataRecord 及其 SqlMetaData。 然后,该示例使用 SendResultsStart 方法标记结果集的开头,使用 SendResultsRow 方法将包含示例数据的记录发送回客户端,并使用 SendResultsEnd 方法标记结果集的末尾。

[Microsoft.SqlServer.Server.SqlProcedure]
public static void StoredProcReturnResultSet()
{
    // Create the record and specify the metadata for the columns.
    SqlDataRecord record = new SqlDataRecord(
        new SqlMetaData("col1", SqlDbType.NVarChar, 100),
        new SqlMetaData("col2", SqlDbType.Int));

    // Mark the begining of the result-set.
    SqlContext.Pipe.SendResultsStart(record);

    // Send 10 rows back to the client.
    for (int i = 0; i < 10; i++)
    {
        // Set values for each column in the row.
        record.SetString(0, "row " + i.ToString());
        record.SetInt32(1, i);

        // Send the row back to the client.
        SqlContext.Pipe.SendResultsRow(record);
    }

    // Mark the end of the result-set.
    SqlContext.Pipe.SendResultsEnd();
}
<Microsoft.SqlServer.Server.SqlProcedure()> _
Public Shared Sub StoredProcReturnResultSet()

    ' Create the record and specify the metadata for the columns.
    Dim record As New SqlDataRecord( _
        New SqlMetaData("col1", SqlDbType.NVarChar, 100), _
        New SqlMetaData("col2", SqlDbType.Int))

    ' Mark the begining of the result-set.
    SqlContext.Pipe.SendResultsStart(record)

    ' Send 10 rows back to the client.
    Dim i As Integer
    For i = 0 To 9

        ' Set values for each column in the row.
        record.SetString(0, "row " & i.ToString())
        record.SetInt32(1, i)

        ' Send the row back to the client.
        SqlContext.Pipe.SendResultsRow(record)
    Next

    ' Mark the end of the result-set.
    SqlContext.Pipe.SendResultsEnd()
End Sub

注解

托管存储过程可以将结果集发送到未实现 的 SqlDataReader客户端。 此方法与 SendResultsStartSendResultsRow一起允许存储过程将自定义结果集发送到客户端。

适用于

另请参阅