SqlPipe.SendResultsRow(SqlDataRecord) Метод

Определение

Отправляет клиенту одну строку данных.

public:
 void SendResultsRow(Microsoft::SqlServer::Server::SqlDataRecord ^ record);
public void SendResultsRow (Microsoft.SqlServer.Server.SqlDataRecord record);
member this.SendResultsRow : Microsoft.SqlServer.Server.SqlDataRecord -> unit
Public Sub SendResultsRow (record As SqlDataRecord)

Параметры

record
SqlDataRecord

Объект SqlDataRecord, содержащий значения столбцов для строки, отправляемой клиенту. Схема для записи должна соответствовать схеме, описанной метаданными объекта SqlDataRecord, переданного в метод SendResultsStart(SqlDataRecord).

Исключения

Значение параметра recordnull.

Перед этим не был вызван метод SendResultsStart(SqlDataRecord).

Примеры

В следующем примере создается новый 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. Этот метод вместе с SendResultsStart и SendResultsEndпозволяет хранимым процедурам отправлять клиенту пользовательские результирующие наборы.

Метод SendResultsRow отправляет клиенту одну строку данных. Строки могут быть впоследствии возвращены вызывающей объекту путем вызова SendResultsRowпо одному разу для каждой отправляемой строки. После отправки всех строк требуется SendResultsEnd вызов метода , чтобы отметить конец результирующих наборов.

Применяется к

См. также раздел