The addNew method of the Recordset class creates a new record for an updatable Recordset object. addNew has the following signatures:
addNew()
addNew(Object[] valueList)
addNew(Object[] fieldList, Object[] valueList)
The behavior of addNew depends on the updating mode of the Recordset object and whether you pass the fieldList and valueList arguments.
In immediate update mode (the provider writes changes to the underlying data source once you call update), calling addNew without arguments sets EditMode to ADD. The provider caches any field value changes locally. Calling update posts the new record to the database and resets EditMode to NONE. If you pass the fieldList and valueList arguments, ADO immediately posts the new record to the database (no update call is necessary); EditMode does not change (NONE).
In batch update mode (the provider caches multiple changes and writes them to the underlying data source only when you call updateBatch), calling addNew without arguments sets EditMode to ADD. The provider caches any field value changes locally. Calling update adds the new record to the current recordset and resets EditMode to NONE, but the provider does not post the changes to the underlying database until you call updateBatch. If you pass the fieldList and valueList arguments, ADO sends the new record to the provider for storage in a cache; you need to call updateBatch to post the new record to the underlying database.
Creates and initializes a new record, and sets AdoEnums.EditMode to ADD.
public void addNew();
Creates and initializes a new record from an object array.
public void addNew(Object[] valueList);
valueList | An array of values for the fields in the new record. If fieldList is an array, valueList must also be an array with the same number of members; otherwise, an error occurs. The order of field names must match the order of field values in each array. |
In immediate update mode, immediately posts the new record to the database. In batch update mode, causes the new record to be sent to the provider for storage in a cache. A call to updateBatch is required to post the new record to the underlying database.
public void addNew(Object[] fieldList, Object[] valueList);
fieldList | A single name, or an array of names or ordinal positions of the fields in the new record. |
valueList | A single value, or an array of values for the fields in the new record. If fieldList is an array, valueList must also be an array with the same number of members; otherwise, an error occurs. The order of field names must match the order of field values in each array. |