Class Recordset
- Namespace
- PolarDataInterop
- Assembly
- PolarDataInterop.dll
This class provides an interface with data in the database.
public class Recordset : PolarWeakEventListener, IDisposable
- Inheritance
-
Recordset
- Implements
- Derived
- Inherited Members
- Extension Methods
Fields
adAffectCurrent
ADO constant
public const int adAffectCurrent = 1
Field Value
adBookmarkFirst
ADO constant
public const int adBookmarkFirst = 1
Field Value
adBookmarkLast
ADO constant
public const int adBookmarkLast = 2
Field Value
adClipString
ADO constant
public const int adClipString = 2
Field Value
adExecuteNoRecords
ADO constant
public const int adExecuteNoRecords = 128
Field Value
adFldUnknownUpdatable
ADO constant
public const int adFldUnknownUpdatable = 8
Field Value
adFldUpdatable
ADO constant
public const int adFldUpdatable = 4
Field Value
adRecConcurrencyViolation
The status of the recordset in case of a concurrency violation (flag).
public const int adRecConcurrencyViolation = 2048
Field Value
adRecDBDeleted
The status of the recordset in case the record has been deleted (flag).
public const int adRecDBDeleted = 262144
Field Value
Properties
AbsolutePosition
Gets/sets the 1-based absolute position. Not supported by static recordsets.
public virtual long AbsolutePosition { get; set; }
Property Value
BaseTableName
Returns the name of the base table.
public string BaseTableName { get; }
Property Value
Bof
Returns True if the beginning of the file has been reached.
public bool Bof { get; }
Property Value
Connection
The connection used to communicate with the database.
public PolarConnection Connection { get; }
Property Value
Dirty
Returns True if there are fields with unsaved changes.
public bool Dirty { get; }
Property Value
Eof
Returns True if the end of the file has been reached.
public bool Eof { get; }
Property Value
Fields
Returns the fields in this recordset.
public Collection<Field> Fields { get; }
Property Value
this[object]
This default property returns a field by 0-based index or name (case-insensitive).
public Field this[object Key] { get; }
Parameters
Key
objectThe 0-based index or name.
Property Value
- Field
The found field.
RecordCount
public long RecordCount { get; }
Property Value
RecordDeleted
Returns True if the current record has been deleted from the database.
public bool RecordDeleted { get; }
Property Value
RecordsAffected
Returns the number of affected records. Returns -1 if not applicable.
public int RecordsAffected { get; }
Property Value
Source
Returns the sql string used to open this recordset.
public string Source { get; }
Property Value
Updatable
Returns True if the records can be updated.
public bool Updatable { get; }
Property Value
Methods
AddNew()
Creates a new, empty record that can be stored in the database with an .Update
public Recordset AddNew()
Returns
- Recordset
This recordset.
Exceptions
- Exception
An error message may be thrown if the query is not updatable or a new record is still pending.
CancelUpdate()
Cancels any pending changes.
public virtual Recordset CancelUpdate()
Returns
- Recordset
This recordset.
Clone()
Creates a clone of the current recordset.
public virtual Recordset Clone()
Returns
- Recordset
A new recordset.
Close()
Closes the recordset and frees resources.
public void Close()
Delete()
Deletes the current record without removing it from the list of records.
public virtual bool Delete()
Returns
- bool
A boolean indicating success.
Exceptions
- Exception
Throws an exception if the query is not updatable.
Dispose()
Disposal.
public virtual void Dispose()
~Recordset()
Destructor.
protected ~Recordset()
Find(string, long)
Finds the primary field with the specified name and value.
public bool Find(string pPrimaryKeyFieldName, long pPrimaryKeyValue)
Parameters
pPrimaryKeyFieldName
stringThe name of the primary key field to search on.
pPrimaryKeyValue
longThe value to search for.
Returns
- bool
A Boolean indicating success.
GetData(int, bool)
Returns a collection of dictionaries with the data for each row in this recordset. Warning: Make sure no 'move nexts' have been carried out to prevent losing data.
public Collection GetData(int pRecordCount = -1, bool pSkipNullValues = false)
Parameters
pRecordCount
intThe number of records to convert. Use -1 for all. If pRecordCount = 0 , a collection with only the current record is returned and the recordset will not move to the next record
pSkipNullValues
boolIf True, all NULL values will omitted from the dictionaries.
Returns
- Collection
A collection with dictionaries.
GetDataRecord(bool)
Returns the data of the current record in a dictionary.
public Dictionary GetDataRecord(bool pSkipNullValues = false)
Parameters
pSkipNullValues
boolIf True, all NULL values will omitted from the dictionary.
Returns
- Dictionary
A dictionary with all the fields.
GetEnumerator()
Enumerator to enumerate over the fields.
public IEnumerator GetEnumerator()
Returns
- IEnumerator
The Fields enumerator
GetJSON(int, bool)
This method creates JSON for the current recordset. Warning: Make sure no 'move nexts' have been carried out to prevent losing data.
public string GetJSON(int pRecordCount = -1, bool pSkipNullValues = false)
Parameters
pRecordCount
intThe number of records to convert. Use -1 for all. If pRecordCount = 0 , only the current record is returned and the recordset will not move to the next record
pSkipNullValues
boolIf True, all NULL values will omitted from the JSON.
Returns
- string
The JSON for this recordset.
GetRows(long)
Returns a two-dimensional array with the data of this recordset. The first index is the field, the second index the row(!), thus object[{FieldCount}, {RecordCount}]. Warning: Make sure no 'move nexts' have been carried out to prevent losing data.
public object[,] GetRows(long pNumRows = -1)
Parameters
pNumRows
longThe maximum number of rows to return. Use -1 for unlimited.
Returns
- object[,]
An array with the data.
GetString(int, int, string, string, string)
Returns the contents of the recordset as string. Warning: Make sure no 'move nexts' have been carried out to prevent losing data.
public string GetString(int pDummyStringFormat = 2, int pNumRows = -1, string pColumnDelimiter = "\t", string pRowDelimiter = "\r\n", string pNullExpr = "")
Parameters
pDummyStringFormat
intDummy parameter for backwards compatibility. Not used.
pNumRows
intThe max number of rows to return. Use -1 for all.
pColumnDelimiter
stringThe string to put between columns.
pRowDelimiter
stringThe string to put after each row (also after the first row).
pNullExpr
stringThis string is put in place of NULL-values
Returns
- string
The string
MoveFirst()
Move to the first record. For static recordsets, this is actually a requery.
public virtual bool MoveFirst()
Returns
- bool
True data is available.
MoveLast()
Move to the next record. Only for dynamic recordsets.
public virtual bool MoveLast()
Returns
- bool
True if data is available.
Exceptions
- Exception
Throws an exception if not possible for the current type of recordset.
MoveNext()
Move to the next record.
public virtual bool MoveNext()
Returns
- bool
True if data is available.
MovePrevious()
Move to the previous record. Only for dynamic recordsets.
public virtual bool MovePrevious()
Returns
- bool
True if data is available
Exceptions
- Exception
Throws an exception if not possible for the current type of recordset.
NextRecordset()
Activates the next recordset in case of a query that returned multiple recordsets.
public virtual Recordset NextRecordset()
Returns
- Recordset
The next recordset (effectively 'this') or Nothing if no further recordsets available.
Exceptions
- Exception
May throw and exception for updatable recordsets
OnWeakEvent(PolarWeakEvent, params object[])
Interface for weak events. Used internally.
public void OnWeakEvent(PolarWeakEvent pWeakEvent, params object[] pParameters)
Parameters
pWeakEvent
PolarWeakEventpParameters
object[]
Requery()
Re-runs the query and retrieves the newest data from the database.
public virtual Recordset Requery()
Returns
- Recordset
This recordset
Resync()
Resync the current record with the data in the database.
public virtual void Resync()
Exceptions
- Exception
Throws an exception in case of failure.
TryResync()
Tries to resync the current record with the data in the database.
public virtual void TryResync()
Exceptions
- Exception
Throws an exception in case of failure.
Update()
Updates the changes in the database.
public virtual Recordset Update()
Returns
- Recordset
This recordset.