Export (0) Print
Expand All

SqlCeResultSet Class

An updateable, scrollable, and bindable cursor.

Namespace:  System.Data.SqlServerCe
Assembly:  System.Data.SqlServerCe (in System.Data.SqlServerCe.dll)

public class SqlCeResultSet : SqlCeDataReader, 
	IEnumerable, IListSource

The SqlCeResultSet type exposes the following members.

  NameDescription
Protected methodSqlCeResultSetSecurity Critical. Do not use. To create a SqlCeResultSet, you must call the ExecuteResultSet(ResultSetOptions) method of the SqlCeCommand.
Top

  NameDescription
Protected propertyContainsListCollectionInfrastructure.
Public propertyDepthGets a value indicating the depth of nesting for the current row. (inherited from SqlCeDataReader)
Public propertyFieldCountGets the number of columns in the query's SELECT clause. (inherited from SqlCeDataReader)
Public propertyHasRowsGets a value that indicates whether the SqlCeDataReader contains one or more rows (inherited from SqlCeDataReader)
Public propertyHiddenFieldCountInfrastructure. (inherited from SqlCeDataReader)
Public propertyIsClosedIndicates whether the data reader is closed. (inherited from SqlCeDataReader)
Public propertyItem[Int32]Serves as an indexer for the SqlCeResultSet. (Overrides SqlCeDataReader.Item[Int32].)
Public propertyItem[String]Serves as an indexer for the SqlCeResultSet. (Overrides SqlCeDataReader.Item[String].)
Public propertyRecordsAffectedGets the number of rows changed, inserted, or deleted by execution of the SQL statement. (inherited from SqlCeDataReader)
Public propertyResultSetViewUsed when data binding a SqlCeResultSet to a control.
Public propertyScrollableDetermines whether the SqlCeResultSet is scrollable.
Public propertySensitivityDetermines the sensitivity of the SqlCeResultSet.
Public propertyUpdatableDetermines whether values within the SqlCeResultSet can be modified.
Public propertyVisibleFieldCount (inherited from DbDataReader)
Top

  NameDescription
Public methodCloseCloses the SqlCeDataReader object. (inherited from SqlCeDataReader)
Public methodCreateObjRef (inherited from MarshalByRefObject)
Public methodCreateRecordCreates a new row on the server and returns a SqlCeUpdatableRecord object.
Public methodDeleteDeletes the current record from the data source on the server.
Public methodDispose()Infrastructure. Releases the resources consumed by this SqlCeDataReader. (inherited from SqlCeDataReader)
Protected methodDispose(Boolean)Releases the unmanaged resources used by this SqlCeDataReader, and optionally releases the managed resources as well. (inherited from SqlCeDataReader)
Public methodEquals (inherited from Object)
Protected methodFinalizeReleases unmanaged resources and performs other cleanup operations before the SqlCeDataReader is reclaimed by garbage collection. (inherited from SqlCeDataReader)
Public methodGetBooleanReturns the value of the column at the specified index as a Boolean value. (Overrides SqlCeDataReader.GetBoolean(Int32).)
Public methodGetByteReturns the value of the column at the specified index as a byte. (Overrides SqlCeDataReader.GetByte(Int32).)
Public methodGetBytesCopies a length of bytes into the buffer, starting at a specified position in the specified field. (Overrides SqlCeDataReader.GetBytes(Int32, Int64, Byte[], Int32, Int32).)
Public methodGetCharNot supported in the .NET Compact Framework Data Provider for SQL Server Compact. (inherited from SqlCeDataReader)
Public methodGetCharsCopies a length of chars into the buffer, starting at a specified position in the specified field. (Overrides SqlCeDataReader.GetChars(Int32, Int64, Char[], Int32, Int32).)
Public methodGetData (inherited from DbDataReader)
Public methodGetDataTypeNameGets the name of the source data type. (inherited from SqlCeDataReader)
Public methodGetDateTimeReturns the value of the column at the specified index as a DateTime. (Overrides SqlCeDataReader.GetDateTime(Int32).)
Protected methodGetDbDataReader (inherited from DbDataReader)
Public methodGetDecimalReturns the value of the column at the specified index as a Double. (Overrides SqlCeDataReader.GetDecimal(Int32).)
Public methodGetDoubleReturns the value of the column at the specified index as a Double. (Overrides SqlCeDataReader.GetDouble(Int32).)
Public methodGetEnumeratorReturns a IEnumerator that can be used to iterate through the rows in the data reader. (Overrides SqlCeDataReader.GetEnumerator().)
Public methodGetFieldTypeGets the Type that is the data type of the object. (inherited from SqlCeDataReader)
Public methodGetFloatReturns the value of the column at the specified index as a Float. (Overrides SqlCeDataReader.GetFloat(Int32).)
Public methodGetGuidReturns the value of the column at the specified index as a GUID. (Overrides SqlCeDataReader.GetGuid(Int32).)
Public methodGetHashCode (inherited from Object)
Public methodGetInt16Returns the value of the column at the specified index as an Int16. (Overrides SqlCeDataReader.GetInt16(Int32).)
Public methodGetInt32Returns the value of the column at the specified index as an Int32. (Overrides SqlCeDataReader.GetInt32(Int32).)
Public methodGetInt64Returns the value of the column at the specified index as an Int64. (Overrides SqlCeDataReader.GetInt64(Int32).)
Public methodGetLifetimeService (inherited from MarshalByRefObject)
Protected methodGetListReturns an instance of ResultSetView.
Public methodGetNameGets the name of the specified column. (inherited from SqlCeDataReader)
Public methodGetOrdinalGets the column ordinal, given the name of the column. (inherited from SqlCeDataReader)
Public methodGetProviderSpecificFieldTypeGets a Object that is a representation of the underlying provider-specific field type. (inherited from SqlCeDataReader)
Public methodGetProviderSpecificValue (inherited from DbDataReader)
Public methodGetProviderSpecificValues (inherited from DbDataReader)
Public methodGetSchemaTableReturns a DataTable that describes the column metadata of the SqlCeDataReader. (inherited from SqlCeDataReader)
Public methodGetSqlBinaryReturns the value of the column at the specified index as type SqlBinary. (Overrides SqlCeDataReader.GetSqlBinary(Int32).)
Public methodGetSqlBooleanReturns the value of the column at the specified index as type SqlBoolean. (Overrides SqlCeDataReader.GetSqlBoolean(Int32).)
Public methodGetSqlByteReturns the value of the column at the specified index as type SqlByte. (Overrides SqlCeDataReader.GetSqlByte(Int32).)
Public methodGetSqlDateTimeReturns the value of the column at the specified index as type SqlDateTime. (Overrides SqlCeDataReader.GetSqlDateTime(Int32).)
Public methodGetSqlDecimalReturns the value of the column at the specified index as type SqlDecimal. (Overrides SqlCeDataReader.GetSqlDecimal(Int32).)
Public methodGetSqlDoubleReturns the value of the column at the specified index as type SqlDouble. (Overrides SqlCeDataReader.GetSqlDouble(Int32).)
Public methodGetSqlGuidReturns the value of the column at the specified index as type SqlGuid. (Overrides SqlCeDataReader.GetSqlGuid(Int32).)
Public methodGetSqlInt16Returns the value of the column at the specified index as type SqlInt16. (Overrides SqlCeDataReader.GetSqlInt16(Int32).)
Public methodGetSqlInt32Returns the value of the column at the specified index as type SqlInt32. (Overrides SqlCeDataReader.GetSqlInt32(Int32).)
Public methodGetSqlInt64Returns the value of the column at the specified index as type SqlInt64. (Overrides SqlCeDataReader.GetSqlInt64(Int32).)
Public methodGetSqlMetaDataReturns the metadata information associated with the specified column.
Public methodGetSqlMoneyReturns the value of the column at the specified index as type SqlMoney. (Overrides SqlCeDataReader.GetSqlMoney(Int32).)
Public methodGetSqlSingleReturns the value of the column at the specified index as type SqlSingle. (Overrides SqlCeDataReader.GetSqlSingle(Int32).)
Public methodGetSqlStringReturns the value of the column at the specified index as type SqlString. (Overrides SqlCeDataReader.GetSqlString(Int32).)
Public methodGetStringReturns the value of the column at the specified index as type String. (Overrides SqlCeDataReader.GetString(Int32).)
Public methodGetType (inherited from Object)
Public methodGetValueReturns the value of the specified field. (Overrides SqlCeDataReader.GetValue(Int32).)
Public methodGetValuesRetrieves an array of all of the fields for the specified record. (Overrides SqlCeDataReader.GetValues(Object[]).)
Public methodInitializeLifetimeService (inherited from MarshalByRefObject)
Public methodInsert(SqlCeUpdatableRecord)Inserts the specified SqlCeUpdatableRecord into the underlying rowset.
Public methodInsert(SqlCeUpdatableRecord, DbInsertOptions)Inserts the specified SqlCeUpdatableRecord into the underlying rowset and specifies how the cursor is positioned.
Protected methodIsCommandBehaviorDetermines whether the specified CommandBehavior matches that of this SqlCeDataReader. (inherited from SqlCeDataReader)
Public methodIsDBNullDetermines if the field at the specified ordinal position is null. (Overrides SqlCeDataReader.IsDBNull(Int32).)
Public methodIsSetAsDefaultDetermines if the field at the specified ordinal position is marked to use the underlying default value.
Protected methodMemberwiseClone() (inherited from Object)
Protected methodMemberwiseClone(Boolean) (inherited from MarshalByRefObject)
Public methodNextResultNot supported in the .NET Compact Framework Data Provider for SQL Server Compact. (inherited from SqlCeDataReader)
Protected methodOnMoveInfrastructure. (Overrides SqlCeDataReader.OnMove().)
Public methodReadAdvances SqlCeDataReader to the next record. (inherited from SqlCeDataReader)
Public methodReadAbsoluteMoves the reader to a specific record in the ResultSet.
Public methodReadFirstPositions the reader at the first record in the ResultSet.
Public methodReadLastPositions the reader at the last record in the ResultSet.
Public methodReadPreviousPositions the reader at the record pervious to the current record.
Public methodReadRelativeMoves the reader the specified amount from the current position.
Public methodSeekPlaces the SqlCeDataReader on the record with indexed values that match the specified parameters. (inherited from SqlCeDataReader)
Public methodSetBooleanSets the value of the specified column to the passed-in Boolean value.
Public methodSetByteSets the value of the specified column to the passed-in Byte value.
Public methodSetBytesCopies a length of bytes from the specified buffer to the specified column, starting at the specified location within that field.
Public methodSetCharSets the value of the specified column to the passed-in Char value.
Public methodSetCharsCopies a length of chars from the specified buffer to the specified column, starting at the specified location within that field.
Public methodSetDateTimeSets the value of the specified column to the passed-in DateTime value.
Public methodSetDecimalSets the value of the specified column to the passed-in Decimal value.
Public methodSetDefaultSets the specified column to its default value.
Public methodSetDoubleSets the value of the specified column to the passed-in Double value.
Public methodSetFloatSets the value of the specified column to the passed-in Float value.
Public methodSetGuidSets the value of the specified column to the passed-in Guid value.
Public methodSetInt16Sets the value of the specified column to the passed-in Int16 value.
Public methodSetInt32Sets the value of the specified column to the passed-in Int32 value.
Public methodSetInt64Sets the value of the specified column to the passed-in Int64 value.
Public methodSetObjectRefBinds an object to the column at the specified position.
Public methodSetSqlBinarySets the value of the specified column to the passed-in SqlBinary value.
Public methodSetSqlBooleanSets the value of the specified column to the passed-in SqlBoolean value.
Public methodSetSqlByteSets the value of the specified column to the passed-in SqlByte value.
Public methodSetSqlDateTimeSets the value of the specified column to the passed-in SqlDateTime value.
Public methodSetSqlDecimalSets the value of the specified column to the passed-in SqlDecimal value.
Public methodSetSqlDoubleSets the value of the specified column to the passed-in SqlDouble value.
Public methodSetSqlGuidSets the value of the specified column to the passed-in SqlGuid value.
Public methodSetSqlInt16Sets the value of the specified column to the passed-in SqlInt16 value.
Public methodSetSqlInt32Sets the value of the specified column to the passed-in SqlInt32 value.
Public methodSetSqlInt64Sets the value of the specified column to the passed-in SqlInt64 value.
Public methodSetSqlMoneySets the value of the specified column to the passed-in SqlMoney value.
Public methodSetSqlSingleSets the value of the specified column to the passed-in SqlSingle value.
Public methodSetSqlStringSets the value of the specified column to the passed-in SqlString value.
Public methodSetStringSets the value of the specified column to the passed-in String value.
Public methodSetValueSets the value of the specified column to the passed-in value.
Public methodSetValuesSets each of the fields in the specified record to the corresponding value in the specified array.
Public methodToString (inherited from Object)
Public methodUpdateSends changes from the current record to the underlying row on the server.
Top

In earlier versions of SQL Server Compact, to bind controls to data, you had to use a DataSet. While a SqlCeDataReader provides better performance than a DataSet, it is a forward-only, non-updateable cursor. In SQL Server Compact, the SqlCeResultSet provides a combination of functionality: the updateability and scrollability of the DataSet plus performance similar to a SqlCeDataReader.

To create a SqlCeResultSet, you must call the ExecuteResultSet method rather than using the object's constructor.

The ResultSetOptions let you specify the scrollabilty, updatability, and sensitivity (which determines if the SqlCeResultSet sees changes made by itself or others) of the SqlCeResultSet.

The default position of the SqlCeDataReader is prior to the first record. To begin accessing any data, you must call Read. The first Read will position the cursor to the first record. The behaviour is different from that of SqlCeResultSet.Read method. The default position of the SqlCeResultSet is the first record. Calling SqlCeResultSet.Read method immediately after creating the SqlCeResultSet will move the cursor to the second record.

In the following example, a new SQL Server Compact database is created. A SqlCeResultSet is then initialized to populate the dataset with data.

SqlCeConnection conn = null;

try
{
    File.Delete("Test.sdf");

    SqlCeEngine engine = new SqlCeEngine("Data Source = Test.sdf");
    engine.CreateDatabase();

    conn = new SqlCeConnection("Data Source = Test.sdf");
    conn.Open();

    SqlCeCommand cmd = conn.CreateCommand();
    cmd.CommandText = "CREATE TABLE myTable (col1 INT, col2 MONEY, col3 NVARCHAR(200))";
    cmd.ExecuteNonQuery();

    cmd.CommandText = "SELECT * FROM myTable";

    SqlCeResultSet rs = cmd.ExecuteResultSet(ResultSetOptions.Updatable | 
        ResultSetOptions.Scrollable);

    SqlCeUpdatableRecord rec = rs.CreateRecord();

    rec.SetInt32(0, 34);
    rec.SetDecimal(1, (decimal)44.66);
    rec.SetString(2, "Sample text");

    rs.Insert(rec);
}
catch (Exception e)
{
    MessageBox.Show(e.Message);
}
finally
{
    conn.Close();
}


Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft