Adding a Row Using a Result Set Position

Accessing and Changing Relational Data

Accessing and Changing Relational Data

Adding a Row Using a Result Set Position

The ADO, OLE DB and ODBC application programming interfaces (APIs) support adding rows while processing the result set of a query. The fundamental process is to:

  1. Bind the result set columns to program variables.

  2. Execute the query.

  3. Execute API functions or methods to position the application on a row within the result set.

  4. Fill the bound program variables with the data values for the new row to be inserted.

  5. Execute one of these functions or methods to insert the row:
    • In ADO, call the AddNew method of the Recordset object.

    • In OLE DB, call the InsertRow method of the IRowsetChange interface.

    • In ODBC 3.x, call the SQLBulkOperations function with the SQL_ADD option.

The new row is not necessarily inserted at a position based on the application's position within the result set. The new row is inserted at a position in the base tables related to the values of any clustered key values specified.