Table of Contents

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

int

adBookmarkFirst

ADO constant

public const int adBookmarkFirst = 1

Field Value

int

adBookmarkLast

ADO constant

public const int adBookmarkLast = 2

Field Value

int

adClipString

ADO constant

public const int adClipString = 2

Field Value

int

adExecuteNoRecords

ADO constant

public const int adExecuteNoRecords = 128

Field Value

int

adFldUnknownUpdatable

ADO constant

public const int adFldUnknownUpdatable = 8

Field Value

int

adFldUpdatable

ADO constant

public const int adFldUpdatable = 4

Field Value

int

adRecConcurrencyViolation

The status of the recordset in case of a concurrency violation (flag).

public const int adRecConcurrencyViolation = 2048

Field Value

int

adRecDBDeleted

The status of the recordset in case the record has been deleted (flag).

public const int adRecDBDeleted = 262144

Field Value

int

Properties

AbsolutePosition

Gets/sets the 1-based absolute position. Not supported by static recordsets.

public virtual long AbsolutePosition { get; set; }

Property Value

long

BaseTableName

Returns the name of the base table.

public string BaseTableName { get; }

Property Value

string

Bof

Returns True if the beginning of the file has been reached.

public bool Bof { get; }

Property Value

bool

Connection

The connection used to communicate with the database.

public PolarConnection Connection { get; }

Property Value

PolarConnection

Dirty

Returns True if there are fields with unsaved changes.

public bool Dirty { get; }

Property Value

bool

Eof

Returns True if the end of the file has been reached.

public bool Eof { get; }

Property Value

bool

Fields

Returns the fields in this recordset.

public Collection<Field> Fields { get; }

Property Value

Collection<Field>

this[object]

This default property returns a field by 0-based index or name (case-insensitive).

public Field this[object Key] { get; }

Parameters

Key object

The 0-based index or name.

Property Value

Field

The found field.

RecordCount

public long RecordCount { get; }

Property Value

long

RecordDeleted

Returns True if the current record has been deleted from the database.

public bool RecordDeleted { get; }

Property Value

bool

RecordsAffected

Returns the number of affected records. Returns -1 if not applicable.

public int RecordsAffected { get; }

Property Value

int

Source

Returns the sql string used to open this recordset.

public string Source { get; }

Property Value

string

Updatable

Returns True if the records can be updated.

public bool Updatable { get; }

Property Value

bool

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 string

The name of the primary key field to search on.

pPrimaryKeyValue long

The 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 int

The 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 bool

If 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 bool

If 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 int

The 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 bool

If 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 long

The 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 int

Dummy parameter for backwards compatibility. Not used.

pNumRows int

The max number of rows to return. Use -1 for all.

pColumnDelimiter string

The string to put between columns.

pRowDelimiter string

The string to put after each row (also after the first row).

pNullExpr string

This 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 PolarWeakEvent
pParameters 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.