SqlPipe.SendResultsEnd Methode

Definition

Markiert das Ende eines Resultsets und setzt die SqlPipe-Instanz auf den Ausgangszustand zurück.

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

Ausnahmen

Die SendResultsStart(SqlDataRecord)-Methode wurde zuvor nicht aufgerufen.

Beispiele

Im folgenden Beispiel werden ein neues SqlDataRecord und dessen SqlMetaDataerstellt. Das Beispiel markiert dann den Anfang eines Resultsets mithilfe der SendResultsStart -Methode, sendet Datensätze mit Beispieldaten mithilfe der SendResultsRow -Methode zurück an den Client und markiert das Ende des Resultsets mit der SendResultsEnd -Methode.

[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

Hinweise

Verwaltete gespeicherte Prozeduren können Resultsets an Clients senden, die keine implementieren SqlDataReader. Mit dieser Methode und SendResultsStartSendResultsRowkönnen gespeicherte Prozeduren benutzerdefinierte Resultsets an den Client senden.

Gilt für:

Weitere Informationen