Sign in Join
FPDoc Onlineexperiment

TDataSet class

In unit DB

Base class for records-based data-access.

Declaration

pascal
TDataSet = class(TComponent)

Inheritance

  1. TDataSet
  2. TComponent
  3. TPersistent
  4. TObject

Descends from it: TDBDataset TMemDataset

Description

TDataset is the main class of the db unit. This abstract class provides all basic functionality to access data stored in tabular format: The data consists of records, and the data in each record is organised in several fields.

TDataset has a buffer to cache a few records in memory, this buffer is used by TDatasource to create the ability to use data-aware components.

TDataset is an abstract class, which provides the basic functionality to access, navigate through the data and - in case read-write access is available, edit existing or add new records.

TDataset is an abstract class: it does not have the knowledge to store or load the records from whatever medium the records are stored on. Descendants add the functionality to load and save the data. Therefor TDataset is never used directly, one always instantiates a descendent class.

Initially, no data is available: the dataset is inactive. The Open method must be used to fetch data into memory. After this command, the data is available in memory for browsing or editing purposes: The dataset is active (indicated by the Active property). Likewise, the Close method can be used to remove the data from memory. Any changes not yet saved to the underlying medium will be lost.

Data is expected to be in tabular format, where each row represents a record. The dataset has an idea of a cursor: this is the current position of the data cursor in the set of rows. Only the data of the current record is available for display or editing purposes. Through the Next, Prev, First and Last methods, it is possible to navigate through the records. The EOF property will be True if the last row has been reached. Likewise, the BOF property will return True if the first record in the dataset has been reached when navigating backwards. If both properties are empty, then there is no data available. For dataset descendents that support counting the number of records, the RecordCount will be zero.

The Append and Insert methods can be used to insert new records to the set of records. The Delete statement is used to delete the current record, and the Edit command must be used to set the dataset in editing mode: the contents of the current record can then be changed. Any changes made to the current record (be it a new or existing record) must be saved by the Post method, or can be undone using the Cancel method.

The data in the various fields properties is available through the Fields array property, giving indexed access to all the fields in a record. The contents of a field is always readable. If the dataset is in one of the editing modes, then the fields can also be written to.

See also

Properties

ActiveRecordprotected
CurrentRecordprotected
BlobFieldCountprotected
BookmarkSizeprotected
Buffersprotected
BufferCountprotected
CalcBufferprotected
CalcFieldsSizeprotected
InternalCalcFieldsprotected
Constraintsprotected
MyDataSourcesprotected
MyDataSourceCountprotected
BlockReadSizepublicNumber of records to read.
BOFpublicIs the cursor at the beginning of the data (on the first record).
BookmarkpublicGet or set the current cursor position.
CanModifypublicCan the data in the dataset be modified.
DataSourcepublicDatasource this dataset is connected to.
DefaultFieldspublicIs the dataset using persistent fields or not.
EOFpublicIndicates whether the last record has been reached.
FieldCountpublicNumber of fields.
FieldDefspublicDefinitions of available fields in the underlying database.
FoundpublicCheck success of one of the Find methods.
ModifiedpublicWas the current record modified ?
IsUniDirectionalpublicIs the dataset unidirectional (i.e. forward scrolling only).
RecordCountpublicNumber of records in the dataset.
RecNopublicCurrent record number.
RecordSizepublicSize of the record in memory.
SparseArrayspublic
StatepublicCurrent operational state of the dataset.
FieldspublicIndexed access to the fields of the dataset.
FieldValuespublicAccess to field values based on the field names.
FilterpublicFilter to apply to the data in memory.
FilteredpublicIs the filter active or not.
FilterOptionspublicOptions to apply when filtering.
ActivepublicIs the dataset open or closed.
AutoCalcFieldspublicHow often should the value of calculated fields be calculated.
BeforeOpenpublicEvent triggered before the dataset is opened.
AfterOpenpublicEvent triggered after the dataset is opened.
BeforeClosepublicEvent triggered before the dataset is closed.
AfterClosepublicEvent triggered after the dataset is closed.
BeforeInsertpublicEvent triggered before the dataset is put in insert mode.
AfterInsertpublicEvent triggered after the dataset is put in insert mode.
BeforeEditpublicEvent triggered before the dataset is put in edit mode.
AfterEditpublicEvent triggered after the dataset is put in edit mode.
BeforePostpublicEvent called before changes are posted to the underlying database.
AfterPostpublicEvent called after changes have been posted to the underlying database.
BeforeCancelpublicEvent triggered before a Cancel operation.
AfterCancelpublicEvent triggered after a Cancel operation.
BeforeDeletepublicEvent triggered before a Delete operation.
AfterDeletepublicEvent triggered after a successful Delete operation.
BeforeScrollpublicEvent triggered before the cursor changes position.
AfterScrollpublicEvent triggered after the cursor has changed position.
BeforeRefreshpublicEvent triggered before the data is refreshed.
AfterRefreshpublicEvent triggered after the data has been refreshed.

Methods

GetDefaultBufferCountprotected
RecalcBufListSizeprotected
ActivateBuffersprotected
BindFieldsprotected
BlockReadNextprotected
BookmarkAvailableprotected
CalculateFieldsprotected
CheckActiveprotected
CheckInactiveprotected
CheckBiDirectionalprotected
LoadedprotectedCalled when the component has finished loading.
ClearBuffersprotected
ClearCalcFieldsprotected
CloseBlobprotected
CloseCursorprotected
CreateFieldsprotected
DataEventprotected
DestroyFieldsprotected
DoAfterCancelprotected
DoAfterCloseprotected
DoAfterDeleteprotected
DoAfterEditprotected
DoAfterInsertprotected
DoAfterOpenprotected
DoAfterPostprotected
DoAfterScrollprotected
DoAfterRefreshprotected
DoBeforeCancelprotected
DoBeforeCloseprotected
DoBeforeDeleteprotected
DoBeforeEditprotected
DoBeforeInsertprotected
DoBeforeOpenprotected
DoBeforePostprotected
DoBeforeScrollprotected
DoBeforeRefreshprotected
DoOnCalcFieldsprotected
DoOnNewRecordprotected
FieldByNumberprotected
FindRecordprotected
FreeFieldBuffersprotected
GetBookmarkStrprotected
GetCalcFieldsprotected
GetCanModifyprotected
GetChildrenprotectedMust be overridden by descendants to return all child components that must be streamed.
GetFieldClassprotected
GetfieldCountprotected
GetFieldValuesprotected
GetIsIndexFieldprotected
GetIndexDefsprotected
GetNextRecordsprotected
GetNextRecordprotected
GetPriorRecordsprotected
GetPriorRecordprotected
GetRecordCountprotected
GetRecNoprotected
InitFieldDefsprotected
InitFieldDefsFromFieldsprotected
InitRecordprotected
InternalCancelprotected
InternalEditprotected
InternalInsertprotected
InternalRefreshprotected
OpenCursorprotected
OpenCursorcompleteprotected
RefreshInternalCalcFieldsprotected
RestoreStateprotected
SetActiveprotected
SetBookmarkStrprotected
SetBufListSizeprotected
SetChildOrderprotectedDetermines the order in which children are streamed/created.
SetCurrentRecordprotected
SetDefaultFieldsprotected
SetFilteredprotected
SetFilterOptionsprotected
SetFilterTextprotected
SetFieldValuesprotected
SetFoundprotected
SetModifiedprotected
SetNameprotectedWrite handler for Name property.
SetOnFilterRecordprotected
SetRecNoprotected
SetStateprotected
SetTempStateprotected
TempBufferprotected
UpdateIndexDefsprotected
AllocRecordBufferprotected
FreeRecordBufferprotected
GetBookmarkDataprotected
GetBookmarkFlagprotected
GetDataSourceprotected
GetRecordSizeprotected
InternalAddRecordprotected
InternalDeleteprotected
InternalFirstprotected
InternalGotoBookmarkprotected
InternalHandleExceptionprotected
InternalInitRecordprotected
InternalLastprotected
InternalPostprotected
InternalSetToRecordprotected
SetBookmarkFlagprotected
SetBookmarkDataprotected
SetUniDirectionalprotected
FieldDefsClassprotected
FieldsClassprotected
GetRecordprotected
InternalCloseprotected
InternalOpenprotected
InternalInitFieldDefsprotected
IsCursorOpenprotected
PSEndTransactionprotected
PSExecuteprotected
PSExecuteStatementprotected
PSGetAttributesprotected
PSGetCommandTextprotected
PSGetCommandTypeprotected
PSGetDefaultOrderprotected
PSGetIndexDefsprotected
PSGetKeyFieldsprotected
PSGetParamsprotected
PSGetQuoteCharprotected
PSGetTableNameprotected
PSGetUpdateExceptionprotected
PSInTransactionprotected
PSIsSQLBasedprotected
PSIsSQLSupportedprotected
PSResetprotected
PSSetCommandTextprotected
PSSetParamsprotected
PSStartTransactionprotected
PSUpdateRecordprotected
CreatepublicCreate a new TDataset instance.
DestroypublicFree a TDataset instance.
ActiveBufferpublicCurrently active memory buffer.
GetFieldDatapublicGet the data for a field.
SetFieldDatapublicStore the data for a field.
AppendpublicAppend a new record to the data.
AppendRecordpublicAppend a new record to the dataset and fill with data.
BookmarkValidpublicTest whether ABookMark is a valid bookmark.
CancelpublicCancel the current editing operation.
CheckBrowseModepublicCheck whether the dataset is in browse mode.
ClearFieldspublicClear the values of all fields.
ClosepublicClose the dataset.
ControlsDisabledpublicCheck whether the controls are disabled.
CompareBookmarkspublicCompare two bookmarks.
CreateBlobStreampublicCreate blob stream.
CursorPosChangedpublicIndicate a change in cursor position.
DataConvertpublicConvert data from/to native format.
DeletepublicDelete the current record.
DisableControlspublicDisable event propagation of controls.
EditpublicSet the dataset in editing mode.
EnableControlspublicEnable event propagation of controls.
FieldByNamepublicSearch a field by name.
FindFieldpublicFind a field by name.
FindFirstpublicFind the first active record (deprecated).
FindLastpublicFind the last active record (deprecated).
FindNextpublicFind the next active record (deprecated).
FindPriorpublicFind the previous active record (deprecated).
FirstpublicPosition the dataset on the first record.
FreeBookmarkpublicFree a bookmark obtained with GetBookmark (deprecated).
GetBookmarkpublicGet a bookmark pointer (deprecated).
GetCurrentRecordpublicCopy the data for the current record in a memory buffer.
GetFieldListpublicReturn field instances in a list.
GetFieldNamespublicReturn a list of all available field names.
GotoBookmarkpublicJump to bookmark.
InsertpublicInsert a new record at the current position.
InsertRecordpublicInsert a new record with given values.
IsEmptypublicCheck if the dataset contains no data.
IsLinkedTopublicCheck whether a datasource is linked to the dataset.
IsSequencedpublicIs the data sequenced.
LastpublicNavigate forward to the last record.
LocatepublicLocate a record based on some key values.
LookuppublicSearch for a record and return matching values.
MoveBypublicMove the cursor position.
NextpublicGo to the next record in the dataset.
OpenpublicActivate the dataset: Fetch data into memory.
PostpublicPost pending edits to the database.
PriorpublicGo to the previous record.
RefreshpublicRefresh the records in the dataset.
ResyncpublicResynchronize the data buffer.
SetFieldspublicSet a number of field values at once.
TranslatepublicTransliterate a buffer.
UpdateCursorPospublicUpdate cursor position.
UpdateRecordpublicIndicate that the record contents have changed.
UpdateStatuspublicGet the update status for the current record.

Events

OnCalcFieldspublicEvent triggered when values for calculated fields must be computed.
OnDeleteErrorpublicEvent triggered when a delete operation fails.
OnEditErrorpublicEvent triggered when an edit operation fails.
OnFilterRecordpublicEvent triggered to filter records.
OnNewRecordpublicEvent triggered when a new record is created.
OnPostErrorpublicEvent triggered when a post operation fails.

Inherited

From TComponent (70)

_AddRef _Release BeforeDestruction CanObserve ChangeName ComObject ComponentCount ComponentIndex Components ComponentState ComponentStyle DefineProperties DesignInfo DestroyComponents Destroying ExecuteAction FindComponent FreeNotification FreeOnRelease GetChildOwner GetChildParent GetDeltaStreams GetEnumerator GetIDsOfNames GetNamePath GetObservers GetOwner GetParentComponent GetTypeInfo GetTypeInfoCount HasParent iicrGetComponent InsertComponent Invoke IsImplementorOf Loading Name Notification ObserverAdded Observers OnGetDeltaStreams Owner PaletteCreated QueryInterface ReadDeltaState ReadDeltaStream ReadState ReferenceInterface RemoveComponent RemoveFreeNotification RemoveFreeNotifications SafeCallException SetAncestor SetDesigning SetDesignInstance SetInline SetParentComponent SetSubComponent Tag ToString TToStringNameMode UpdateAction Updated UpdateRegistry Updating ValidateContainer ValidateInsert ValidateRename VCLComObject WriteState

From TPersistent (5)

Assign AssignTo FPOAttachObserver FPODetachObserver FPONotifyObservers

From TObject (37)

AfterConstruction CheckDisposed ClassInfo ClassName ClassNameIs ClassParent ClassType CleanupInstance DefaultHandler DefaultHandlerStr Dispatch DispatchStr Disposed DisposeOf Equals FieldAddress Free FreeInstance GetDisposed GetHashCode GetInterface GetInterfaceByStr GetInterfaceEntry GetInterfaceEntryByStr GetInterfaceTable GetInterfaceWeak GetLastCastErrorInfo InheritsFrom InitInstance InstanceSize MethodAddress MethodName newinstance QualifiedClassName StringMessageTable SystemHasExtendedRTTI UnitName

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.