Enabling Insertion of New Records
Go Up to Determining and Setting Dataset States
A dataset must be in dsInsert
mode before an application can add new records. In your code you can use the Insert
or Append
methods to put a dataset into dsInsert
mode if the read-only CanModify
property for the dataset is True
. CanModify
is True
if the database underlying a dataset permits read and write privileges.
On forms in your application, the data-aware grid and navigator controls can put a dataset into dsInsert
state if
- The
ReadOnly
property of the control isFalse
(the default), - The
AutoEdit
property of the data source for the control isTrue
, and CanModify
isTrue
for the dataset.
For
TIBTable
components, if the ReadOnly
property is True
, CanModify
is False, preventing editing of records.Even if a dataset is in
dsInsert
state, inserting records will not succeed for InterBase databases if your application user does not have proper SQL access privileges.You can return a dataset from dsInsert
state to dsBrowse
state in code by calling the Cancel
, Post
, or Delete
methods. Delete
and Cancel
discard the new record. Post
attempts to write the new record to the dataset, and if it succeeds, returns the dataset to dsBrowse
. If Post
cannot write the record, the dataset remains in dsInsert
state.
Data-aware controls for which inserting is enabled automatically call Post
when a user executes any action that changes the current record (such as moving to a different record in a grid).
For more discussion of inserting and appending records in a dataset, see Modifying Dataset Data.