Enabling Dataset Editing

From InterBase

Go Up to Determining and Setting Dataset States


A dataset must be in dsEdit mode before an application can modify records. In your code you can use the Edit method to put a dataset into dsEdit 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, some data-aware controls can automatically put a dataset into dsEdit state if:

  • The ReadOnly property of the control is False (the default),
  • The AutoEdit property of the data source for the control is True, and
  • CanModify is True for the dataset.
Important:
For TIBTable components, if the ReadOnly property is True, CanModify is False, preventing editing of records.
Note:
Even if a dataset is in dsEdit state, editing records will not succeed for InterBase databases if your application user does not have proper SQL access privileges.

You can return a dataset from dsEdit state to dsBrowse state in code by calling the Cancel, Post, or Delete methods. Cancel discards edits to the current field or record. Post attempts to write a modified record to the dataset, and if it succeeds, returns the dataset to dsBrowse. If Post cannot write changes, the dataset remains in dsEdit state. Delete attempts to remove the current record from the dataset, and if it succeeds, returns the dataset to dsBrowse state. If Delete fails, the dataset remains in dsEdit state.

Data-aware controls for which editing 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) or that causes the control to lose focus (such as moving to a different control on the form).

For a complete discussion of editing fields and records in a dataset, see Modifying Dataset Data.

Advance To: