SqlDataRecord 類別

定義

表示資料的單一資料列及其中繼資料 (Metadata)。 此類別無法獲得繼承。

public ref class SqlDataRecord : System::Data::IDataRecord
public class SqlDataRecord : System.Data.IDataRecord
type SqlDataRecord = class
    interface IDataRecord
Public Class SqlDataRecord
Implements IDataRecord
繼承
SqlDataRecord
實作

範例

下列範例示範如何建立數 SqlMetaData 個物件,其中描述記錄的資料行中繼資料,以及建立 SqlDataRecord 。 的資料行值 SqlDataRecord 會設定,並使用 SqlDataRecord 類別傳送至呼叫程式 SqlContext

[Microsoft.SqlServer.Server.SqlProcedure]
public static void CreateNewRecord()
{

   // 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[] { new SqlMetaData("Column1", SqlDbType.NVarChar, 12),
                                                  new SqlMetaData("Column2", SqlDbType.Int),
                                                  new SqlMetaData("Column3", SqlDbType.DateTime) });

   // Set the record fields.
   record.SetString(0, "Hello World!");
   record.SetInt32(1, 42);
   record.SetDateTime(2, DateTime.Now);

   // Send the record to the calling program.
   SqlContext.Pipe.Send(record);
}
<Microsoft.SqlServer.Server.SqlProcedure()> _
Public Shared Sub CreateNewRecord()

   ' Variables.
   Dim record As SqlDataRecord
   
   ' Create a new record with the column metadata.  The constructor is 
   ' able to accept a variable number of parameters.     
   record = New SqlDataRecord(New SqlMetaData() {New SqlMetaData("Column1", SqlDbType.NVarChar, 12), _
                                                 New SqlMetaData("Column2", SqlDbType.Int), _
                                                 New SqlMetaData("Column3", SqlDbType.DateTime)})

   ' Set the record fields.
   record.SetString(0, "Hello World!")
   record.SetInt32(1, 42)
   record.SetDateTime(2, DateTime.Now)

   ' Send the record to the calling program.
   SqlContext.Pipe.Send(record)

End Sub

備註

這個類別會與 搭配 SqlPipe 使用,從 Managed 程式碼預存程式將結果集傳送至用戶端。

撰寫 Common Language Runtime (CLR) 應用程式時,您應該重複使用現有的 SqlDataRecord 物件,而不是每次建立新的物件。 建立許多新 SqlDataRecord 物件可能會嚴重耗盡記憶體,並對效能造成負面影響。

建構函式

SqlDataRecord(SqlMetaData[])

根據做為引數傳遞的 SqlMetaData 物件陣列,使用結構描述來初始化新的 SqlDataRecord 執行個體。

屬性

FieldCount

取得此資料列中的資料行數目。 這個屬性是唯讀的。

Item[Int32]

取得資料行 ordinal 引數所指定之資料行的通用語言執行平台 (CLR) 類型值。

Item[String]

取得資料行 name 引數所指定之資料行的通用語言執行平台 (CLR) 類型值。

方法

GetBoolean(Int32)

取得序數所指定資料行的 Boolean 值。

GetByte(Int32)

取得序數所指定資料行的 Byte 值。

GetBytes(Int32, Int64, Byte[], Int32, Int32)

取得資料行的值,其由該序數指定為 Byte 物件陣列。

GetChar(Int32)

取得序數所指定資料行的 Char 值。

GetChars(Int32, Int64, Char[], Int32, Int32)

取得資料行的值,其由該序數指定為 Char 物件陣列。

GetDataTypeName(Int32)

傳回序數引數所指定資料行的資料類型名稱。

GetDateTime(Int32)

取得序數所指定資料行的 DateTime 值。

GetDateTimeOffset(Int32)

傳回指定的資料行資料作為 DateTimeOffset

GetDecimal(Int32)

取得序數所指定資料行的 Decimal 值。

GetDouble(Int32)

取得序數所指定資料行的 Double 值。

GetFieldType(Int32)

傳回 Type 物件,代表 Common Language Runtime (CLR) 類型,該類型對應至 ordinal 引數指定之資料行的 SQL Server 類型。

GetFloat(Int32)

取得序數所指定資料行的 float 值。

GetGuid(Int32)

取得序數所指定資料行的 Guid 值。

GetInt16(Int32)

取得序數所指定資料行的 Int16 值。

GetInt32(Int32)

取得序數所指定資料行的 Int32 值。

GetInt64(Int32)

取得序數所指定資料行的 Int64 值。

GetName(Int32)

傳回序數引數所指定的資料行名稱。

GetOrdinal(String)

傳回資料行名稱所指定的資料行序數。

GetSqlBinary(Int32)

取得序數所指定資料行的 SqlBinary 值。

GetSqlBoolean(Int32)

取得序數所指定資料行的 SqlBoolean 值。

GetSqlByte(Int32)

取得序數所指定資料行的 SqlByte 值。

GetSqlBytes(Int32)

取得序數所指定資料行的 SqlBytes 值。

GetSqlChars(Int32)

取得序數所指定資料行的 SqlChars 值。

GetSqlDateTime(Int32)

取得序數所指定資料行的 SqlDateTime 值。

GetSqlDecimal(Int32)

取得序數所指定資料行的 SqlDecimal 值。

GetSqlDouble(Int32)

取得序數所指定資料行的 SqlDouble 值。

GetSqlFieldType(Int32)

傳回表示類型的 Type 物件 (如 System.Data.SqlTypes 中定義的 SQL Server 類型),其可對應到資料行的 SQL Server 類型。

GetSqlGuid(Int32)

取得序數所指定資料行的 SqlGuid 值。

GetSqlInt16(Int32)

取得序數所指定資料行的 SqlInt16 值。

GetSqlInt32(Int32)

取得序數所指定資料行的 SqlInt32 值。

GetSqlInt64(Int32)

取得序數所指定資料行的 SqlInt64 值。

GetSqlMetaData(Int32)

傳回 SqlMetaData 物件,描述資料行序數所指定的資料行中繼資料。

GetSqlMoney(Int32)

取得序數所指定資料行的 SqlMoney 值。

GetSqlSingle(Int32)

取得序數所指定資料行的 SqlSingle 值。

GetSqlString(Int32)

取得序數所指定資料行的 SqlString 值。

GetSqlValue(Int32)

傳回儲存在資料行、以 SQL Server 類型表示,並由資料行序數指定的資料值。

GetSqlValues(Object[])

傳回陣列記錄中所有資料行的值,表示為 SQL Server 類型。

GetSqlXml(Int32)

取得序數所指定資料行的 SqlXml 值。

GetString(Int32)

取得序數所指定資料行的 String 值。

GetTimeSpan(Int32)

傳回指定的資料行資料作為 TimeSpan

GetValue(Int32)

傳回序數引數所指定資料行的 Common Language Runtime (CLR) 類型值。

GetValues(Object[])

傳回陣列記錄中所有資料行的值,表示為通用語言執行平台 (CLR) 類型。

IsDBNull(Int32)

如果資料行序數參數所指定的資料行為 Null,則傳回 True,

SetBoolean(Int32, Boolean)

將儲存在資料行的資料設定為指定的 Boolean 值。

SetByte(Int32, Byte)

將儲存在資料行的資料設定為指定的 Byte 值。

SetBytes(Int32, Int64, Byte[], Int32, Int32)

將儲存在資料行的資料設定為 Byte 值的指定陣列。

SetChar(Int32, Char)

將儲存在資料行的資料設定為指定的 Char 值。

SetChars(Int32, Int64, Char[], Int32, Int32)

將儲存在資料行的資料設定為 Char 值的指定陣列。

SetDateTime(Int32, DateTime)

將儲存在資料行的資料設定為指定的 DateTime 值。

SetDateTimeOffset(Int32, DateTimeOffset)

將指定的資料行值設為 DateTimeOffset 值。

SetDBNull(Int32)

設定指定資料行中的值為 DBNull

SetDecimal(Int32, Decimal)

將儲存在資料行的資料設定為指定的 Decimal 值。

SetDouble(Int32, Double)

將儲存在資料行的資料設定為指定的 Double 值。

SetFloat(Int32, Single)

將儲存在資料行的資料設定為指定的 float 值。

SetGuid(Int32, Guid)

將儲存在資料行的資料設定為指定的 Guid 值。

SetInt16(Int32, Int16)

將儲存在資料行的資料設定為指定的 Int16 值。

SetInt32(Int32, Int32)

將儲存在資料行的資料設定為指定的 Int32 值。

SetInt64(Int32, Int64)

將儲存在資料行的資料設定為指定的 Int64 值。

SetSqlBinary(Int32, SqlBinary)

將儲存在資料行的資料設定為指定的 SqlBinary 值。

SetSqlBoolean(Int32, SqlBoolean)

將儲存在資料行的資料設定為指定的 SqlBoolean 值。

SetSqlByte(Int32, SqlByte)

將儲存在資料行的資料設定為指定的 SqlByte 值。

SetSqlBytes(Int32, SqlBytes)

將儲存在資料行的資料設定為指定的 SqlBytes 值。

SetSqlChars(Int32, SqlChars)

將儲存在資料行的資料設定為指定的 SqlChars 值。

SetSqlDateTime(Int32, SqlDateTime)

將儲存在資料行的資料設定為指定的 SqlDateTime 值。

SetSqlDecimal(Int32, SqlDecimal)

將儲存在資料行的資料設定為指定的 SqlDecimal 值。

SetSqlDouble(Int32, SqlDouble)

將儲存在資料行的資料設定為指定的 SqlDouble 值。

SetSqlGuid(Int32, SqlGuid)

將儲存在資料行的資料設定為指定的 SqlGuid 值。

SetSqlInt16(Int32, SqlInt16)

將儲存在資料行的資料設定為指定的 SqlInt16 值。

SetSqlInt32(Int32, SqlInt32)

將儲存在資料行的資料設定為指定的 SqlInt32 值。

SetSqlInt64(Int32, SqlInt64)

將儲存在資料行的資料設定為指定的 SqlInt64 值。

SetSqlMoney(Int32, SqlMoney)

將儲存在資料行的資料設定為指定的 SqlMoney 值。

SetSqlSingle(Int32, SqlSingle)

將儲存在資料行的資料設定為指定的 SqlSingle 值。

SetSqlString(Int32, SqlString)

將儲存在資料行的資料設定為指定的 SqlString 值。

SetSqlXml(Int32, SqlXml)

將儲存在資料行的資料設定為指定的 SqlXml 值。

SetString(Int32, String)

將儲存在資料行的資料設定為指定的 String 值。

SetTimeSpan(Int32, TimeSpan)

將指定的資料行值設為 TimeSpan

SetValue(Int32, Object)

設定資料行序數指定之資料行的新值,以 Common Language Runtime (CLR) 類型表示。

SetValues(Object[])

SqlDataRecord 中的所有資料行設定新的值。 這些值會表示為通用語言執行平台 (CLR) 類型。

明確介面實作

IDataRecord.GetData(Int32)

這個版本不支援。

適用於