Controlling Read-Write Access to Tables

From RAD Studio
Jump to: navigation, search

Go Up to Using Table Type Datasets

By default when a table type dataset is opened, it requests read and write access for the underlying database table. Depending on the characteristics of the underlying database table, the requested write privilege may not be granted (for example, when you request write access to an SQL table on a remote server and the server restricts the table's access to read only).

Note: This is not true for TClientDataSet, which determines whether users can edit data from information that the dataset provider supplies with data packets. It is also not true for TSQLTable, which is a unidirectional dataset, and hence always read-only.

When the table opens, you can check the CanModify property to ascertain whether the underlying database (or the dataset provider) allows users to edit the data in the table. If CanModify is False, the application cannot write to the database. If CanModify is True, your application can write to the database provided the table's ReadOnly property is False.

ReadOnly determines whether a user can both view and edit data. When ReadOnly is False (the default), a user can both view and edit data. To restrict a user to viewing data, set ReadOnly to True before opening the table.

Note: ReadOnly is implemented on all table type datasets except TSQLTable, which is always read-only.

See Also