Extracts the fields to save to the database from the objItem.SaveFields function.
The fields are then written to the database using either an SQL INSERT or UPDATE
depending on whether the object has already been saved. If the collection has
implemented IDatabaseObjects.KeyFieldName then objItem's key is also validated to
ensure it is not null and unique within the collection. If objCollection has
implemented IDatabaseObjects.Subset then objItem should exist within objCollection.
If not, a duplicate key error may occur if the obItem's key is being used in
another subset in the same table. If a record is being amended
(IDatabaseObject.IsSaved returns true) then the function will "AND" the collection's
IDatabaseObjects.Subset conditions and the objItem's IDatabaseObject.DistinctValue
value to create the WHERE clause in the UPDATE statement. Therefore, the
combination of the IDatabaseObjects.Subset and IDatabaseObject.DistinctValue
conditions MUST identify only one record in the table. Otherwise multiple records
will be updated with the same data. If data is only inserted and not amended
(usually a rare occurance) then this requirement is unnecessary.
Namespace: DatabaseObjectsAssembly: DatabaseObjects (in DatabaseObjects.dll) Version: 3.8.1.0
Syntax
C# |
---|
public void ObjectSave( IDatabaseObjects objCollection, IDatabaseObject objItem ) |
Visual Basic |
---|
Public Sub ObjectSave ( _ objCollection As IDatabaseObjects, _ objItem As IDatabaseObject _ ) |
Visual C++ |
---|
public: void ObjectSave( IDatabaseObjects^ objCollection, IDatabaseObject^ objItem ) |
Parameters
- objCollection
- Type: DatabaseObjects..::..IDatabaseObjects
The collection which contains or will contain the object to save.
- objItem
- Type: DatabaseObjects..::..IDatabaseObject
The object to save to the database. The values saved to the database are extracted from the SQLFieldValues object returned from IDatabaseObject.SaveFields.
Examples
Saves a product object (Me) to the database.
CopyC#
Public Sub Save() objDatabase.ObjectSave(NorthwindDB.Products, Me) End Sub