ComponentOne DataObjects for .NET
Generated SQL Statements
DataObjects for .NET (Enterprise Edition) > Updating the Database > Generated SQL Statements

When updating a row of a bound table, that is, a simple table with non-empty Connection and DbTableName properties, DataObjects for .NET generates and executes a SQL statement. Generated SQL statements are described in the following sections for each of the three possible cases: inserting, deleting and modifying rows. SQL statements are not generated for unbound and SQL-based tables, see Updating SQL-based and Unbound Tables.

The update process consists of three phases:

Row DELETE has only locate and change phases, no refresh. Row INSERT has only change and refresh phases, no locate. Row UPDATE has all three phases: locate, change, and refresh. The locate and change phases are performed in one SQL statement, locate being the condition in its WHERE clause, change – the action clause (INSERT/DELETE/UPDATE). The refresh phase is performed by a separate SQL SELECT statement finding a single record by its primary key value.

Generated SQL statements contain parameters specifying values used to locate the record in the database and values to assign to record fields. Parameter values are determined by the original and current values in the C1DataRow object:

Parameters used to locate the record are assigned the original field values, that is, the values as they have been fetched from the database before the user could modify them:

row["field_name", DataRowVersionEnum.Original]

Parameters used to set values of record fields are assigned the current values of the row:

row["field_name", DataRowVersionEnum.Current]

The generated parameterized SQL statement is used to set up and execute an IDbCommand object (for OLE DB: .NET Framework class System.Data.OleDb.OleDbCommand, for native SQL Server connection: System.Data.SqlClient, and so on). If necessary, this IDbCommand object can be customized in event code, see Events in Updating a Row.

Executing generated SQL statements is the default processing. It can be customized or substituted altogether with custom code using the BeforeUpdateRow, AfterUpdateRow events, see Events in Updating a Row.

See Also