SqlPipe.SendResultsEnd Método
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Marca el fin de un conjunto de resultados y devuelve la instancia de SqlPipe al estado inicial.
public:
void SendResultsEnd();
public void SendResultsEnd ();
member this.SendResultsEnd : unit -> unit
Public Sub SendResultsEnd ()
Excepciones
No se ha llamado previamente al método SendResultsStart(SqlDataRecord).
Ejemplos
En el ejemplo siguiente se crea un nuevo SqlDataRecord objeto y su SqlMetaData. A continuación, el ejemplo marca el principio de un conjunto de resultados mediante el SendResultsStart método , envía registros con datos de ejemplo al cliente mediante el SendResultsRow método y marca el final del conjunto de resultados con el SendResultsEnd método .
[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
Comentarios
Los procedimientos almacenados administrados pueden enviar conjuntos de resultados a los clientes que no implementan un SqlDataReader. Este método, junto con SendResultsStart y SendResultsRow, permiten que los procedimientos almacenados envíen conjuntos de resultados personalizados al cliente.