SqlDataRecord Class

SqlDataRecord Class

 

Represents a single row of data and its metadata. This class cannot be inherited.

Namespace:   Microsoft.SqlServer.Server
Assembly:  System.Data (in System.Data.dll)

System.Object
  Microsoft.SqlServer.Server.SqlDataRecord

public class SqlDataRecord : IDataRecord

NameDescription
System_CAPS_pubmethodSqlDataRecord(SqlMetaData[])

Inititializes a new SqlDataRecord instance with the schema based on the array of SqlMetaData objects passed as an argument.

NameDescription
System_CAPS_pubpropertyFieldCount

Gets the number of columns in the data row. This property is read-only.

System_CAPS_pubpropertyItem[Int32]

Gets the common language runtime (CLR) type value for the column specified by the column ordinal argument.

System_CAPS_pubpropertyItem[String]

Gets the common language runtime (CLR) type value for the column specified by the column name argument.

NameDescription
System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetBoolean(Int32)

Gets the value for the column specified by the ordinal as a Boolean.

System_CAPS_pubmethodGetByte(Int32)

Gets the value for the column specified by the ordinal as a Byte.

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

Gets the value for the column specified by the ordinal as an array of Byte objects.

System_CAPS_pubmethodGetChar(Int32)

Gets the value for the column specified by the ordinal as a Char.

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

Gets the value for the column specified by the ordinal as an array of Char objects.

System_CAPS_pubmethodGetDataTypeName(Int32)

Returns the name of the data type for the column specified by the ordinal argument.

System_CAPS_pubmethodGetDateTime(Int32)

Gets the value for the column specified by the ordinal as a DateTime.

System_CAPS_pubmethodGetDateTimeOffset(Int32)

Returns the specified column’s data as a DateTimeOffset.

System_CAPS_pubmethodGetDecimal(Int32)

Gets the value for the column specified by the ordinal as a Decimal.

System_CAPS_pubmethodGetDouble(Int32)

Gets the value for the column specified by the ordinal as a Double.

System_CAPS_pubmethodGetFieldType(Int32)

Returns a Type object representing the common language runtime (CLR) type that maps to the SQL Server type of the column specified by the ordinal argument.

System_CAPS_pubmethodGetFloat(Int32)

Gets the value for the column specified by the ordinal as a float.

System_CAPS_pubmethodGetGuid(Int32)

Gets the value for the column specified by the ordinal as a Guid.

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetInt16(Int32)

Gets the value for the column specified by the ordinal as a Int16.

System_CAPS_pubmethodGetInt32(Int32)

Gets the value for the column specified by the ordinal as a Int32.

System_CAPS_pubmethodGetInt64(Int32)

Gets the value for the column specified by the ordinal as a Int64.

System_CAPS_pubmethodGetName(Int32)

Returns the name of the column specified by the ordinal argument.

System_CAPS_pubmethodGetOrdinal(String)

Returns the column ordinal specified by the column name.

System_CAPS_pubmethodGetSqlBinary(Int32)

Gets the value for the column specified by the ordinal as a SqlBinary.

System_CAPS_pubmethodGetSqlBoolean(Int32)

Gets the value for the column specified by the ordinal as a SqlBoolean.

System_CAPS_pubmethodGetSqlByte(Int32)

Gets the value for the column specified by the ordinal as a SqlByte.

System_CAPS_pubmethodGetSqlBytes(Int32)

Gets the value for the column specified by the ordinal as a SqlBytes.

System_CAPS_pubmethodGetSqlChars(Int32)

Gets the value for the column specified by the ordinal as a SqlChars.

System_CAPS_pubmethodGetSqlDateTime(Int32)

Gets the value for the column specified by the ordinal as a SqlDateTime.

System_CAPS_pubmethodGetSqlDecimal(Int32)

Gets the value for the column specified by the ordinal as a SqlDecimal.

System_CAPS_pubmethodGetSqlDouble(Int32)

Gets the value for the column specified by the ordinal as a SqlDouble.

System_CAPS_pubmethodGetSqlFieldType(Int32)

Returns a Type object that represents the type (as a SQL Server type, defined in System.Data.SqlTypes) that maps to the SQL Server type of the column.

System_CAPS_pubmethodGetSqlGuid(Int32)

Gets the value for the column specified by the ordinal as a SqlGuid.

System_CAPS_pubmethodGetSqlInt16(Int32)

Gets the value for the column specified by the ordinal as a SqlInt16.

System_CAPS_pubmethodGetSqlInt32(Int32)

Gets the value for the column specified by the ordinal as a SqlInt32.

System_CAPS_pubmethodGetSqlInt64(Int32)

Gets the value for the column specified by the ordinal as a SqlInt64.

System_CAPS_pubmethodGetSqlMetaData(Int32)

Returns a SqlMetaData object, describing the metadata of the column specified by the column ordinal.

System_CAPS_pubmethodGetSqlMoney(Int32)

Gets the value for the column specified by the ordinal as a SqlMoney.

System_CAPS_pubmethodGetSqlSingle(Int32)

Gets the value for the column specified by the ordinal as a SqlSingle.

System_CAPS_pubmethodGetSqlString(Int32)

Gets the value for the column specified by the ordinal as a SqlString.

System_CAPS_pubmethodGetSqlValue(Int32)

Returns the data value stored in the column, expressed as a SQL Server type, specified by the column ordinal.

System_CAPS_pubmethodGetSqlValues(Object[])

Returns the values for all the columns in the record, expressed as SQL Server types, in an array.

System_CAPS_pubmethodGetSqlXml(Int32)

Gets the value for the column specified by the ordinal as a SqlXml.

System_CAPS_pubmethodGetString(Int32)

Gets the value for the column specified by the ordinal as a String.

System_CAPS_pubmethodGetTimeSpan(Int32)

Returns the specified column’s data as a TimeSpan.

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodGetValue(Int32)

Returns the common language runtime (CLR) type value for the column specified by the ordinal argument.

System_CAPS_pubmethodGetValues(Object[])

Returns the values for all the columns in the record, expressed as common language runtime (CLR) types, in an array.

System_CAPS_pubmethodIsDBNull(Int32)

Returns true if the column specified by the column ordinal parameter is null.

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodSetBoolean(Int32, Boolean)

Sets the data stored in the column to the specified Boolean value.

System_CAPS_pubmethodSetByte(Int32, Byte)

Sets the data stored in the column to the specified Byte value.

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

Sets the data stored in the column to the specified array of Byte values.

System_CAPS_pubmethodSetChar(Int32, Char)

Sets the data stored in the column to the specified Char value.

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

Sets the data stored in the column to the specified array of Char values.

System_CAPS_pubmethodSetDateTime(Int32, DateTime)

Sets the data stored in the column to the specified DateTime value.

System_CAPS_pubmethodSetDateTimeOffset(Int32, DateTimeOffset)

Sets the value of the column specified to the DateTimeOffset value.

System_CAPS_pubmethodSetDBNull(Int32)

Sets the value in the specified column to DBNull.

System_CAPS_pubmethodSetDecimal(Int32, Decimal)

Sets the data stored in the column to the specified Decimal value.

System_CAPS_pubmethodSetDouble(Int32, Double)

Sets the data stored in the column to the specified Double value.

System_CAPS_pubmethodSetFloat(Int32, Single)

Sets the data stored in the column to the specified float value.

System_CAPS_pubmethodSetGuid(Int32, Guid)

Sets the data stored in the column to the specified Guid value.

System_CAPS_pubmethodSetInt16(Int32, Int16)

Sets the data stored in the column to the specified Int16 value.

System_CAPS_pubmethodSetInt32(Int32, Int32)

Sets the data stored in the column to the specified Int32 value.

System_CAPS_pubmethodSetInt64(Int32, Int64)

Sets the data stored in the column to the specified Int64 value.

System_CAPS_pubmethodSetSqlBinary(Int32, SqlBinary)

Sets the data stored in the column to the specified SqlBinary value.

System_CAPS_pubmethodSetSqlBoolean(Int32, SqlBoolean)

Sets the data stored in the column to the specified SqlBoolean value.

System_CAPS_pubmethodSetSqlByte(Int32, SqlByte)

Sets the data stored in the column to the specified SqlByte value.

System_CAPS_pubmethodSetSqlBytes(Int32, SqlBytes)

Sets the data stored in the column to the specified SqlBytes value.

System_CAPS_pubmethodSetSqlChars(Int32, SqlChars)

Sets the data stored in the column to the specified SqlChars value.

System_CAPS_pubmethodSetSqlDateTime(Int32, SqlDateTime)

Sets the data stored in the column to the specified SqlDateTime value.

System_CAPS_pubmethodSetSqlDecimal(Int32, SqlDecimal)

Sets the data stored in the column to the specified SqlDecimal value.

System_CAPS_pubmethodSetSqlDouble(Int32, SqlDouble)

Sets the data stored in the column to the specified SqlDouble value.

System_CAPS_pubmethodSetSqlGuid(Int32, SqlGuid)

Sets the data stored in the column to the specified SqlGuid value.

System_CAPS_pubmethodSetSqlInt16(Int32, SqlInt16)

Sets the data stored in the column to the specified SqlInt16 value.

System_CAPS_pubmethodSetSqlInt32(Int32, SqlInt32)

Sets the data stored in the column to the specified SqlInt32 value.

System_CAPS_pubmethodSetSqlInt64(Int32, SqlInt64)

Sets the data stored in the column to the specified SqlInt64 value.

System_CAPS_pubmethodSetSqlMoney(Int32, SqlMoney)

Sets the data stored in the column to the specified SqlMoney value.

System_CAPS_pubmethodSetSqlSingle(Int32, SqlSingle)

Sets the data stored in the column to the specified SqlSingle value.

System_CAPS_pubmethodSetSqlString(Int32, SqlString)

Sets the data stored in the column to the specified SqlString value.

System_CAPS_pubmethodSetSqlXml(Int32, SqlXml)

Sets the data stored in the column to the specified SqlXml value.

System_CAPS_pubmethodSetString(Int32, String)

Sets the data stored in the column to the specified String value.

System_CAPS_pubmethodSetTimeSpan(Int32, TimeSpan)

Sets the value of the column specified to the TimeSpan.

System_CAPS_pubmethodSetValue(Int32, Object)

Sets a new value, expressed as a common language runtime (CLR) type, for the column specified by the column ordinal.

System_CAPS_pubmethodSetValues(Object[])

Sets new values for all of the columns in the SqlDataRecord. These values are expressed as common language runtime (CLR) types.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodIDataRecord.GetData(Int32)

Not supported in this release.

This class is used together with SqlPipe to send result sets to the client from managed code stored-procedures.

When writing common language runtime (CLR) applications, you should re-use existing SqlDataRecord objects instead of creating new ones every time. Creating many new SqlDataRecord objects could severely deplete memory and adversely affect performance.

The following example shows how to create several SqlMetaData objects, which describe the column metadata of a record, and creating a SqlDataRecord. The column values of the SqlDataRecord are set and the SqlDataRecord is sent to the calling program by using the SqlContext class.

[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);
}

.NET Framework
Available since 2.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft