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 | |
---|---|---|
SqlCeResultSet | Security Critical. Do not use. To create a SqlCeResultSet, you must call the ExecuteResultSet(ResultSetOptions) method of the SqlCeCommand. |
Top
Properties
Name | Description | |
---|---|---|
ContainsListCollection | Infrastructure. | |
Depth | Gets a value indicating the depth of nesting for the current row. (inherited from SqlCeDataReader) | |
FieldCount | Gets the number of columns in the query's SELECT clause. (inherited from SqlCeDataReader) | |
HasRows | Gets a value that indicates whether the SqlCeDataReader contains one or more rows (inherited from SqlCeDataReader) | |
HiddenFieldCount | Infrastructure. (inherited from SqlCeDataReader) | |
IsClosed | Indicates whether the data reader is closed. (inherited from SqlCeDataReader) | |
Item[Int32] | Serves as an indexer for the SqlCeResultSet. (Overrides SqlCeDataReader.Item[Int32].) | |
Item[String] | Serves as an indexer for the SqlCeResultSet. (Overrides SqlCeDataReader.Item[String].) | |
RecordsAffected | Gets the number of rows changed, inserted, or deleted by execution of the SQL statement. (inherited from SqlCeDataReader) | |
ResultSetView | Used when data binding a SqlCeResultSet to a control. | |
Scrollable | Determines whether the SqlCeResultSet is scrollable. | |
Sensitivity | Determines the sensitivity of the SqlCeResultSet. | |
Updatable | Determines whether values within the SqlCeResultSet can be modified. | |
VisibleFieldCount | (inherited from DbDataReader) |
Top
Methods
Name | Description | |
---|---|---|
Close | Closes the SqlCeDataReader object. (inherited from SqlCeDataReader) | |
CreateObjRef | (inherited from MarshalByRefObject) | |
CreateRecord | Creates a new row on the server and returns a SqlCeUpdatableRecord object. | |
Delete | Deletes the current record from the data source on the server. | |
Dispose() | Infrastructure. Releases the resources consumed by this SqlCeDataReader. (inherited from SqlCeDataReader) | |
Dispose(Boolean) | Releases the unmanaged resources used by this SqlCeDataReader, and optionally releases the managed resources as well. (inherited from SqlCeDataReader) | |
Equals | (inherited from Object) | |
Finalize | Releases unmanaged resources and performs other cleanup operations before the SqlCeDataReader is reclaimed by garbage collection. (inherited from SqlCeDataReader) | |
GetBoolean | Returns the value of the column at the specified index as a Boolean value. (Overrides SqlCeDataReader.GetBoolean(Int32).) | |
GetByte | Returns the value of the column at the specified index as a byte. (Overrides SqlCeDataReader.GetByte(Int32).) | |
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).) | |
GetChar | Not supported in the .NET Compact Framework Data Provider for SQL Server Compact. (inherited from SqlCeDataReader) | |
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).) | |
GetData | (inherited from DbDataReader) | |
GetDataTypeName | Gets the name of the source data type. (inherited from SqlCeDataReader) | |
GetDateTime | Returns the value of the column at the specified index as a DateTime. (Overrides SqlCeDataReader.GetDateTime(Int32).) | |
GetDbDataReader | (inherited from DbDataReader) | |
GetDecimal | Returns the value of the column at the specified index as a Double. (Overrides SqlCeDataReader.GetDecimal(Int32).) | |
GetDouble | Returns the value of the column at the specified index as a Double. (Overrides SqlCeDataReader.GetDouble(Int32).) | |
GetEnumerator | Returns a IEnumerator that can be used to iterate through the rows in the data reader. (Overrides SqlCeDataReader.GetEnumerator().) | |
GetFieldType | Gets the Type that is the data type of the object. (inherited from SqlCeDataReader) | |
GetFloat | Returns the value of the column at the specified index as a Float. (Overrides SqlCeDataReader.GetFloat(Int32).) | |
GetGuid | Returns the value of the column at the specified index as a GUID. (Overrides SqlCeDataReader.GetGuid(Int32).) | |
GetHashCode | (inherited from Object) | |
GetInt16 | Returns the value of the column at the specified index as an Int16. (Overrides SqlCeDataReader.GetInt16(Int32).) | |
GetInt32 | Returns the value of the column at the specified index as an Int32. (Overrides SqlCeDataReader.GetInt32(Int32).) | |
GetInt64 | Returns the value of the column at the specified index as an Int64. (Overrides SqlCeDataReader.GetInt64(Int32).) | |
GetLifetimeService | (inherited from MarshalByRefObject) | |
GetList | Returns an instance of ResultSetView. | |
GetName | Gets the name of the specified column. (inherited from SqlCeDataReader) | |
GetOrdinal | Gets the column ordinal, given the name of the column. (inherited from SqlCeDataReader) | |
GetProviderSpecificFieldType | Gets a Object that is a representation of the underlying provider-specific field type. (inherited from SqlCeDataReader) | |
GetProviderSpecificValue | (inherited from DbDataReader) | |
GetProviderSpecificValues | (inherited from DbDataReader) | |
GetSchemaTable | Returns a DataTable that describes the column metadata of the SqlCeDataReader. (inherited from SqlCeDataReader) | |
GetSqlBinary | Returns the value of the column at the specified index as type SqlBinary. (Overrides SqlCeDataReader.GetSqlBinary(Int32).) | |
GetSqlBoolean | Returns the value of the column at the specified index as type SqlBoolean. (Overrides SqlCeDataReader.GetSqlBoolean(Int32).) | |
GetSqlByte | Returns the value of the column at the specified index as type SqlByte. (Overrides SqlCeDataReader.GetSqlByte(Int32).) | |
GetSqlDateTime | Returns the value of the column at the specified index as type SqlDateTime. (Overrides SqlCeDataReader.GetSqlDateTime(Int32).) | |
GetSqlDecimal | Returns the value of the column at the specified index as type SqlDecimal. (Overrides SqlCeDataReader.GetSqlDecimal(Int32).) | |
GetSqlDouble | Returns the value of the column at the specified index as type SqlDouble. (Overrides SqlCeDataReader.GetSqlDouble(Int32).) | |
GetSqlGuid | Returns the value of the column at the specified index as type SqlGuid. (Overrides SqlCeDataReader.GetSqlGuid(Int32).) | |
GetSqlInt16 | Returns the value of the column at the specified index as type SqlInt16. (Overrides SqlCeDataReader.GetSqlInt16(Int32).) | |
GetSqlInt32 | Returns the value of the column at the specified index as type SqlInt32. (Overrides SqlCeDataReader.GetSqlInt32(Int32).) | |
GetSqlInt64 | Returns the value of the column at the specified index as type SqlInt64. (Overrides SqlCeDataReader.GetSqlInt64(Int32).) | |
GetSqlMetaData | Returns the metadata information associated with the specified column. | |
GetSqlMoney | Returns the value of the column at the specified index as type SqlMoney. (Overrides SqlCeDataReader.GetSqlMoney(Int32).) | |
GetSqlSingle | Returns the value of the column at the specified index as type SqlSingle. (Overrides SqlCeDataReader.GetSqlSingle(Int32).) | |
GetSqlString | Returns the value of the column at the specified index as type SqlString. (Overrides SqlCeDataReader.GetSqlString(Int32).) | |
GetString | Returns the value of the column at the specified index as type String. (Overrides SqlCeDataReader.GetString(Int32).) | |
GetType | (inherited from Object) | |
GetValue | Returns the value of the specified field. (Overrides SqlCeDataReader.GetValue(Int32).) | |
GetValues | Retrieves an array of all of the fields for the specified record. (Overrides SqlCeDataReader.GetValues(array<Object[]).) | |
InitializeLifetimeService | (inherited from MarshalByRefObject) | |
Insert(SqlCeUpdatableRecord) | Inserts the specified SqlCeUpdatableRecord into the underlying rowset. | |
Insert(SqlCeUpdatableRecord, DbInsertOptions) | Inserts the specified SqlCeUpdatableRecord into the underlying rowset and specifies how the cursor is positioned. | |
IsCommandBehavior | Determines whether the specified CommandBehavior matches that of this SqlCeDataReader. (inherited from SqlCeDataReader) | |
IsDBNull | Determines if the field at the specified ordinal position is null. (Overrides SqlCeDataReader.IsDBNull(Int32).) | |
IsSetAsDefault | Determines if the field at the specified ordinal position is marked to use the underlying default value. | |
MemberwiseClone() | (inherited from Object) | |
MemberwiseClone(Boolean) | (inherited from MarshalByRefObject) | |
NextResult | Not supported in the .NET Compact Framework Data Provider for SQL Server Compact. (inherited from SqlCeDataReader) | |
OnMove | Infrastructure. (Overrides SqlCeDataReader.OnMove().) | |
Read | Advances SqlCeDataReader to the next record. (inherited from SqlCeDataReader) | |
ReadAbsolute | Moves the reader to a specific record in the ResultSet. | |
ReadFirst | Positions the reader at the first record in the ResultSet. | |
ReadLast | Positions the reader at the last record in the ResultSet. | |
ReadPrevious | Positions the reader at the record pervious to the current record. | |
ReadRelative | Moves the reader the specified amount from the current position. | |
Seek | Places the SqlCeDataReader on the record with indexed values that match the specified parameters. (inherited from SqlCeDataReader) | |
SetBoolean | Sets the value of the specified column to the passed-in Boolean value. | |
SetByte | Sets the value of the specified column to the passed-in Byte value. | |
SetBytes | Copies a length of bytes from the specified buffer to the specified column, starting at the specified location within that field. | |
SetChar | Sets the value of the specified column to the passed-in Char value. | |
SetChars | Copies a length of chars from the specified buffer to the specified column, starting at the specified location within that field. | |
SetDateTime | Sets the value of the specified column to the passed-in DateTime value. | |
SetDecimal | Sets the value of the specified column to the passed-in Decimal value. | |
SetDefault | Sets the specified column to its default value. | |
SetDouble | Sets the value of the specified column to the passed-in Double value. | |
SetFloat | Sets the value of the specified column to the passed-in Float value. | |
SetGuid | Sets the value of the specified column to the passed-in Guid value. | |
SetInt16 | Sets the value of the specified column to the passed-in Int16 value. | |
SetInt32 | Sets the value of the specified column to the passed-in Int32 value. | |
SetInt64 | Sets the value of the specified column to the passed-in Int64 value. | |
SetObjectRef | Binds an object to the column at the specified position. | |
SetSqlBinary | Sets the value of the specified column to the passed-in SqlBinary value. | |
SetSqlBoolean | Sets the value of the specified column to the passed-in SqlBoolean value. | |
SetSqlByte | Sets the value of the specified column to the passed-in SqlByte value. | |
SetSqlDateTime | Sets the value of the specified column to the passed-in SqlDateTime value. | |
SetSqlDecimal | Sets the value of the specified column to the passed-in SqlDecimal value. | |
SetSqlDouble | Sets the value of the specified column to the passed-in SqlDouble value. | |
SetSqlGuid | Sets the value of the specified column to the passed-in SqlGuid value. | |
SetSqlInt16 | Sets the value of the specified column to the passed-in SqlInt16 value. | |
SetSqlInt32 | Sets the value of the specified column to the passed-in SqlInt32 value. | |
SetSqlInt64 | Sets the value of the specified column to the passed-in SqlInt64 value. | |
SetSqlMoney | Sets the value of the specified column to the passed-in SqlMoney value. | |
SetSqlSingle | Sets the value of the specified column to the passed-in SqlSingle value. | |
SetSqlString | Sets the value of the specified column to the passed-in SqlString value. | |
SetString | Sets the value of the specified column to the passed-in String value. | |
SetValue | Sets the value of the specified column to the passed-in value. | |
SetValues | Sets each of the fields in the specified record to the corresponding value in the specified array. | |
ToString | (inherited from Object) | |
Update | Sends changes from the current record to the underlying row on the server. |
Top
Explicit Interface Implementations
Name | Description | |
---|---|---|
IListSource.ContainsListCollection | ||
IEnumerable.GetEnumerator | ||
IListSource.GetList | ||
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.