Home | Database


 


DataSet States


The DataSet states show the current status that the DataSet is in.

There are many different states:
 
dsBrowse Browse
dsEdit Edit
dsInactive Inactive
dsInsert Insert
dsSetKey SetKey
dsCalcFields CalcFields
dsFilter Filter
dsOpening Open

dsBrowse - Is when the DataSet is open for browsing and this is also the default state.

dsEdit - The DataSet is in Edit mode.

dsInactive - Is when the DataSet is closed and the data is not available to the user.

dsInsert - The DataSet is in insert mode.

dsSetKey - SetKey has been called, but GotoKey hasn't been called yet, the DataSet is in SetKey mode.

dsInactive - This state will indicate that we are not able to use the data, so this would mean that the dataset is closed.

dsCalcFields - Change to non calculated fields are prevented, and calculated fields are being processed.

dsFilter - A filter operation is in process.

dsOpening - The DataSet is opening but it is not finished opening, this is when the dataset is opened for asynchronous fetching.


You can use the above information to show your program users what state the DataSet is in with this code:
 

procedure TForm1.DataSource1StateChange(Sender: TObject);
begin
    case Table1.State of
       dsBrowse    : Label1.Caption := 'Browsing DB';
       dsEdit         : Label1.Caption := 'Editing';
       dsInsert      : Label1.Caption := 'Insert';
    end;
end;

You can add any text you like to Label1.Caption so that the program user understands what is happening for each different state.

Note that we are using the OnStateChange event for a TDataSource component.


Home | Database