次の方法で共有


SqlDataRecord オブジェクト

適用対象:SQL Server

.NET 共通言語ランタイム (CLR) では、SqlDataRecord オブジェクトは、関連するメタデータと共に 1 行のデータを表します。

マネージド ストアド プロシージャは、SqlDataReaderからではないクライアント結果セットに送信される場合があります。 SqlDataRecord クラスは、SqlPipe オブジェクトの SendResultsStartSendResultsRow、および SendResultsEnd メソッドと共に、ストアド プロシージャがカスタム結果セットをクライアントに送信できるようにします。

詳細については、「Microsoft.SqlServer.Server.SqlDataRecordを参照してください。

次の例では、新しい従業員レコードを作成し、これを呼び出し元に返します。

  • C# を する
  • Visual Basic .NET の
[Microsoft.SqlServer.Server.SqlProcedure]
public static void CreateNewRecordProc()
{
    // Variables.
    SqlDataRecord record;

    // Create a new record with the column metadata.  The constructor
    // is able to accept a variable number of parameters.
    record = new SqlDataRecord(new SqlMetaData("EmployeeID", SqlDbType.Int),
                               new SqlMetaData("Surname", SqlDbType.NVarChar, 20),
                               new SqlMetaData("GivenName", SqlDbType.NVarChar, 20),
                               new SqlMetaData("StartDate", SqlDbType.DateTime) );

    // Set the record fields.
    record.SetInt32(0, 0042);
    record.SetString(1, "Funk");
    record.SetString(2, "Don");
    record.SetDateTime(3, new DateTime(2005, 7, 17));

    // Send the record to the calling program.
    SqlContext.Pipe.Send(record);

}
  • SqlPipe オブジェクト の