SqlPipe.SendResultsEnd Metode
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Menandai akhir tataan hasil, dan mengembalikan instans SqlPipe kembali ke status awal.
public:
void SendResultsEnd();
public void SendResultsEnd ();
member this.SendResultsEnd : unit -> unit
Public Sub SendResultsEnd ()
Pengecualian
Metode SendResultsStart(SqlDataRecord) ini sebelumnya tidak dipanggil.
Contoh
Contoh berikut membuat baru SqlDataRecord dan SqlMetaData. Contoh kemudian menandai awal tataan hasil menggunakan SendResultsStart metode , mengirim rekaman dengan contoh data kembali ke klien menggunakan SendResultsRow metode , dan menandai akhir tataan hasil dengan SendResultsEnd metode .
[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
Keterangan
Prosedur tersimpan terkelola dapat mengirim tataan hasil ke klien yang tidak menerapkan SqlDataReader. Metode ini, bersama dengan SendResultsStart dan SendResultsRow, memungkinkan prosedur tersimpan untuk mengirim tataan hasil kustom ke klien.