Aracılığıyla paylaş


SqlCeResultSet Class

An updateable, scrollable, and bindable cursor.

Inheritance Hierarchy

System.Object
  System.MarshalByRefObject
    System.Data.Common.DbDataReader
      System.Data.SqlServerCe.SqlCeDataReader
        System.Data.SqlServerCe.SqlCeResultSet

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

Syntax

'Declaration
Public Class SqlCeResultSet _
    Inherits SqlCeDataReader _
    Implements IEnumerable, IListSource
'Usage
Dim instance As SqlCeResultSet
public class SqlCeResultSet : SqlCeDataReader, 
    IEnumerable, IListSource
public ref class SqlCeResultSet : public SqlCeDataReader, 
    IEnumerable, IListSource
type SqlCeResultSet =  
    class
        inherit SqlCeDataReader
        interface IEnumerable
        interface IListSource
    end
public class SqlCeResultSet extends SqlCeDataReader implements IEnumerable, IListSource

The SqlCeResultSet type exposes the following members.

Constructors

  Name Description
Protected method SqlCeResultSet Security Critical. Do not use. To create a SqlCeResultSet, you must call the ExecuteResultSet(ResultSetOptions) method of the SqlCeCommand.

Top

Properties

  Name Description
Protected property ContainsListCollection Infrastructure.
Public property Depth Gets a value indicating the depth of nesting for the current row. (inherited from SqlCeDataReader)
Public property FieldCount Gets the number of columns in the query's SELECT clause. (inherited from SqlCeDataReader)
Public property HasRows Gets a value that indicates whether the SqlCeDataReader contains one or more rows (inherited from SqlCeDataReader)
Public property HiddenFieldCount Infrastructure. (inherited from SqlCeDataReader)
Public property IsClosed Indicates whether the data reader is closed. (inherited from SqlCeDataReader)
Public property Item[Int32] Serves as an indexer for the SqlCeResultSet. (Overrides SqlCeDataReader.Item[Int32].)
Public property Item[String] Serves as an indexer for the SqlCeResultSet. (Overrides SqlCeDataReader.Item[String].)
Public property RecordsAffected Gets the number of rows changed, inserted, or deleted by execution of the SQL statement. (inherited from SqlCeDataReader)
Public property ResultSetView Used when data binding a SqlCeResultSet to a control.
Public property Scrollable Determines whether the SqlCeResultSet is scrollable.
Public property Sensitivity Determines the sensitivity of the SqlCeResultSet.
Public property Updatable Determines whether values within the SqlCeResultSet can be modified.
Public property VisibleFieldCount (inherited from DbDataReader)

Top

Methods

  Name Description
Public method Close Closes the SqlCeDataReader object. (inherited from SqlCeDataReader)
Public method CreateObjRef (inherited from MarshalByRefObject)
Public method CreateRecord Creates a new row on the server and returns a SqlCeUpdatableRecord object.
Public method Delete Deletes the current record from the data source on the server.
Public method Dispose() Infrastructure. Releases the resources consumed by this SqlCeDataReader. (inherited from SqlCeDataReader)
Protected method Dispose(Boolean) Releases the unmanaged resources used by this SqlCeDataReader, and optionally releases the managed resources as well. (inherited from SqlCeDataReader)
Public method Equals (inherited from Object)
Protected method Finalize Releases unmanaged resources and performs other cleanup operations before the SqlCeDataReader is reclaimed by garbage collection. (inherited from SqlCeDataReader)
Public method GetBoolean Returns the value of the column at the specified index as a Boolean value. (Overrides SqlCeDataReader.GetBoolean(Int32).)
Public method GetByte Returns the value of the column at the specified index as a byte. (Overrides SqlCeDataReader.GetByte(Int32).)
Public method GetBytes Copies a length of bytes into the buffer, starting at a specified position in the specified field. (Overrides SqlCeDataReader.GetBytes(Int32, Int64, array<Byte[], Int32, Int32).)
Public method GetChar Not supported in the .NET Compact Framework Data Provider for SQL Server Compact. (inherited from SqlCeDataReader)
Public method GetChars Copies a length of chars into the buffer, starting at a specified position in the specified field. (Overrides SqlCeDataReader.GetChars(Int32, Int64, array<Char[], Int32, Int32).)
Public method GetData (inherited from DbDataReader)
Public method GetDataTypeName Gets the name of the source data type. (inherited from SqlCeDataReader)
Public method GetDateTime Returns the value of the column at the specified index as a DateTime. (Overrides SqlCeDataReader.GetDateTime(Int32).)
Protected method GetDbDataReader (inherited from DbDataReader)
Public method GetDecimal Returns the value of the column at the specified index as a Double. (Overrides SqlCeDataReader.GetDecimal(Int32).)
Public method GetDouble Returns the value of the column at the specified index as a Double. (Overrides SqlCeDataReader.GetDouble(Int32).)
Public method GetEnumerator Returns a IEnumerator that can be used to iterate through the rows in the data reader. (Overrides SqlCeDataReader.GetEnumerator().)
Public method GetFieldType Gets the Type that is the data type of the object. (inherited from SqlCeDataReader)
Public method GetFloat Returns the value of the column at the specified index as a Float. (Overrides SqlCeDataReader.GetFloat(Int32).)
Public method GetGuid Returns the value of the column at the specified index as a GUID. (Overrides SqlCeDataReader.GetGuid(Int32).)
Public method GetHashCode (inherited from Object)
Public method GetInt16 Returns the value of the column at the specified index as an Int16. (Overrides SqlCeDataReader.GetInt16(Int32).)
Public method GetInt32 Returns the value of the column at the specified index as an Int32. (Overrides SqlCeDataReader.GetInt32(Int32).)
Public method GetInt64 Returns the value of the column at the specified index as an Int64. (Overrides SqlCeDataReader.GetInt64(Int32).)
Public method GetLifetimeService (inherited from MarshalByRefObject)
Protected method GetList Returns an instance of ResultSetView.
Public method GetName Gets the name of the specified column. (inherited from SqlCeDataReader)
Public method GetOrdinal Gets the column ordinal, given the name of the column. (inherited from SqlCeDataReader)
Public method GetProviderSpecificFieldType Gets a Object that is a representation of the underlying provider-specific field type. (inherited from SqlCeDataReader)
Public method GetProviderSpecificValue (inherited from DbDataReader)
Public method GetProviderSpecificValues (inherited from DbDataReader)
Public method GetSchemaTable Returns a DataTable that describes the column metadata of the SqlCeDataReader. (inherited from SqlCeDataReader)
Public method GetSqlBinary Returns the value of the column at the specified index as type SqlBinary. (Overrides SqlCeDataReader.GetSqlBinary(Int32).)
Public method GetSqlBoolean Returns the value of the column at the specified index as type SqlBoolean. (Overrides SqlCeDataReader.GetSqlBoolean(Int32).)
Public method GetSqlByte Returns the value of the column at the specified index as type SqlByte. (Overrides SqlCeDataReader.GetSqlByte(Int32).)
Public method GetSqlDateTime Returns the value of the column at the specified index as type SqlDateTime. (Overrides SqlCeDataReader.GetSqlDateTime(Int32).)
Public method GetSqlDecimal Returns the value of the column at the specified index as type SqlDecimal. (Overrides SqlCeDataReader.GetSqlDecimal(Int32).)
Public method GetSqlDouble Returns the value of the column at the specified index as type SqlDouble. (Overrides SqlCeDataReader.GetSqlDouble(Int32).)
Public method GetSqlGuid Returns the value of the column at the specified index as type SqlGuid. (Overrides SqlCeDataReader.GetSqlGuid(Int32).)
Public method GetSqlInt16 Returns the value of the column at the specified index as type SqlInt16. (Overrides SqlCeDataReader.GetSqlInt16(Int32).)
Public method GetSqlInt32 Returns the value of the column at the specified index as type SqlInt32. (Overrides SqlCeDataReader.GetSqlInt32(Int32).)
Public method GetSqlInt64 Returns the value of the column at the specified index as type SqlInt64. (Overrides SqlCeDataReader.GetSqlInt64(Int32).)
Public method GetSqlMetaData Returns the metadata information associated with the specified column.
Public method GetSqlMoney Returns the value of the column at the specified index as type SqlMoney. (Overrides SqlCeDataReader.GetSqlMoney(Int32).)
Public method GetSqlSingle Returns the value of the column at the specified index as type SqlSingle. (Overrides SqlCeDataReader.GetSqlSingle(Int32).)
Public method GetSqlString Returns the value of the column at the specified index as type SqlString. (Overrides SqlCeDataReader.GetSqlString(Int32).)
Public method GetString Returns the value of the column at the specified index as type String. (Overrides SqlCeDataReader.GetString(Int32).)
Public method GetType (inherited from Object)
Public method GetValue Returns the value of the specified field. (Overrides SqlCeDataReader.GetValue(Int32).)
Public method GetValues Retrieves an array of all of the fields for the specified record. (Overrides SqlCeDataReader.GetValues(array<Object[]).)
Public method InitializeLifetimeService (inherited from MarshalByRefObject)
Public method Insert(SqlCeUpdatableRecord) Inserts the specified SqlCeUpdatableRecord into the underlying rowset.
Public method Insert(SqlCeUpdatableRecord, DbInsertOptions) Inserts the specified SqlCeUpdatableRecord into the underlying rowset and specifies how the cursor is positioned.
Protected method IsCommandBehavior Determines whether the specified CommandBehavior matches that of this SqlCeDataReader. (inherited from SqlCeDataReader)
Public method IsDBNull Determines if the field at the specified ordinal position is null. (Overrides SqlCeDataReader.IsDBNull(Int32).)
Public method IsSetAsDefault Determines if the field at the specified ordinal position is marked to use the underlying default value.
Protected method MemberwiseClone() (inherited from Object)
Protected method MemberwiseClone(Boolean) (inherited from MarshalByRefObject)
Public method NextResult Not supported in the .NET Compact Framework Data Provider for SQL Server Compact. (inherited from SqlCeDataReader)
Protected method OnMove Infrastructure. (Overrides SqlCeDataReader.OnMove().)
Public method Read Advances SqlCeDataReader to the next record. (inherited from SqlCeDataReader)
Public method ReadAbsolute Moves the reader to a specific record in the ResultSet.
Public method ReadFirst Positions the reader at the first record in the ResultSet.
Public method ReadLast Positions the reader at the last record in the ResultSet.
Public method ReadPrevious Positions the reader at the record pervious to the current record.
Public method ReadRelative Moves the reader the specified amount from the current position.
Public method Seek Places the SqlCeDataReader on the record with indexed values that match the specified parameters. (inherited from SqlCeDataReader)
Public method SetBoolean Sets the value of the specified column to the passed-in Boolean value.
Public method SetByte Sets the value of the specified column to the passed-in Byte value.
Public method SetBytes Copies a length of bytes from the specified buffer to the specified column, starting at the specified location within that field.
Public method SetChar Sets the value of the specified column to the passed-in Char value.
Public method SetChars Copies a length of chars from the specified buffer to the specified column, starting at the specified location within that field.
Public method SetDateTime Sets the value of the specified column to the passed-in DateTime value.
Public method SetDecimal Sets the value of the specified column to the passed-in Decimal value.
Public method SetDefault Sets the specified column to its default value.
Public method SetDouble Sets the value of the specified column to the passed-in Double value.
Public method SetFloat Sets the value of the specified column to the passed-in Float value.
Public method SetGuid Sets the value of the specified column to the passed-in Guid value.
Public method SetInt16 Sets the value of the specified column to the passed-in Int16 value.
Public method SetInt32 Sets the value of the specified column to the passed-in Int32 value.
Public method SetInt64 Sets the value of the specified column to the passed-in Int64 value.
Public method SetObjectRef Binds an object to the column at the specified position.
Public method SetSqlBinary Sets the value of the specified column to the passed-in SqlBinary value.
Public method SetSqlBoolean Sets the value of the specified column to the passed-in SqlBoolean value.
Public method SetSqlByte Sets the value of the specified column to the passed-in SqlByte value.
Public method SetSqlDateTime Sets the value of the specified column to the passed-in SqlDateTime value.
Public method SetSqlDecimal Sets the value of the specified column to the passed-in SqlDecimal value.
Public method SetSqlDouble Sets the value of the specified column to the passed-in SqlDouble value.
Public method SetSqlGuid Sets the value of the specified column to the passed-in SqlGuid value.
Public method SetSqlInt16 Sets the value of the specified column to the passed-in SqlInt16 value.
Public method SetSqlInt32 Sets the value of the specified column to the passed-in SqlInt32 value.
Public method SetSqlInt64 Sets the value of the specified column to the passed-in SqlInt64 value.
Public method SetSqlMoney Sets the value of the specified column to the passed-in SqlMoney value.
Public method SetSqlSingle Sets the value of the specified column to the passed-in SqlSingle value.
Public method SetSqlString Sets the value of the specified column to the passed-in SqlString value.
Public method SetString Sets the value of the specified column to the passed-in String value.
Public method SetValue Sets the value of the specified column to the passed-in value.
Public method SetValues Sets each of the fields in the specified record to the corresponding value in the specified array.
Public method ToString (inherited from Object)
Public method Update Sends changes from the current record to the underlying row on the server.

Top

Explicit Interface Implementations

  Name Description
Explicit interface implemetationPrivate property IListSource.ContainsListCollection
Explicit interface implemetationPrivate method IEnumerable.GetEnumerator
Explicit interface implemetationPrivate method IListSource.GetList
Explicit interface implemetationPrivate method IDataRecord.GetData (inherited from DbDataReader)

Top

Remarks

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.

Examples

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

Dim conn As SqlCeConnection = Nothing

Try
    File.Delete("Test.sdf")

    Dim engine As New SqlCeEngine("Data Source = Test.sdf")
    engine.CreateDatabase()

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

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

    cmd.CommandText = "SELECT * FROM myTable"

    Dim rs As SqlCeResultSet = cmd.ExecuteResultSet(ResultSetOptions.Updatable Or ResultSetOptions.Scrollable)

    Dim rec As SqlCeUpdatableRecord = rs.CreateRecord()

    rec.SetInt32(0, 34)
    rec.SetDecimal(1, System.Convert.ToDecimal(44.66))
    rec.SetString(2, "Sample text")

    rs.Insert(rec)
Catch e As Exception
    MessageBox.Show(e.Message)
Finally
    conn.Close()
End Try
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();
}

Thread Safety

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.

See Also

Reference

System.Data.SqlServerCe Namespace