ComponentOne DataObjects for .NET
Updating SQL-Based Tables
DataObjects for .NET (Enterprise Edition) > Updating the Database > Updating SQL-Based and Unbound Tables > Updating SQL-Based Tables

An SQL-based table is a table with DataMode=SqlBased and non-empty Connection property, see Bound, SQL-Based and Unbound Tables. A SQL-based table can have a DataAdapter component associated with it, via the DataAdapter property of the C1TableLogic component (in DataObjects for .NET Express, DataAdapter is a property of C1ExpressTable).

For an SQL-based table with DataAdapter, the update is performed automatically by the DataAdapter component. For an SQL-based table without DataAdapter component, or if DataAdapter does not contain UpdateCommand, InsertCommand, or DeleteCommand, the update is performed in code.

To allow updating the database from an SQL-based table without DataAdapter, write code in the C1TableLogic.BeforeUpdateRow event. According to the state (added/deleted/modified) of the row passed to the event in the Row argument, create one of the three commands (SQL statements in the form of an IDbCommand object), for insert, delete or update correspondingly, and assign the created command object to the corresponding argument: InsertCommand, DeleteCommandor, UpdateCommand.

Optionally, if you need to refresh the updated row from the database, you can create a SELECT command retrieving the updated row and assign it to the SelectCommand argument. For more information, see Changing Data as a Result of Update (Refresh).

Note also, that if the table is read-only or just does not need update functionality, there is no need for update code in any case.