<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><!-- InstanceBegin template="/templates/function.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Database Objects</title>
<!-- InstanceEndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
<link href="default.css" rel="stylesheet" type="text/css">
</head>
<body>
<h1>
<h1><!-- InstanceBeginEditable name="heading" -->DatabaseObjects<!-- InstanceEndEditable --></h1>
<h3><!-- InstanceBeginEditable name="subheader" --> ObjectSave(<span class="keyword">ByVal</span> objCollection <span class="keyword">As</span> IDatabaseObjects,
<span class="keyword">ByVal</span> objItem <span class="keyword">As</span> IDatabaseObject)<!-- InstanceEndEditable --><br>
</h3>
</h1>
<!-- InstanceBeginEditable name="text" -->
<p> ObjectSave extracts the fields to save to the database from the SaveFields
function. ObjectSave then writes the object's record to the database. If the
object has
not yet been
saved to the database then a new record
is inserted. If the
object has already been saved then the record is amended.
The objCollection argument is the collection associated with
the
objItem.
If the collection has implemented <a href="IDatabaseObjects_KeyFieldName.htm">DatabaseObjects_KeyFieldName</a> then
objItem's key is checked to ensure it is not null and is unique within
the collection. If the objCollection has implemented the <a href="IDatabaseObjects_Subset.htm">IDatabaseObjects_Subset</a> function
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. </p>
<p>If a record is being amended (<a href="IDatabaseObject_IsSaved">IDatabaseObject_IsSaved </a>returns
true) then the function will AND the collection's <a href="IDatabaseObjects_Subset.htm">IDatabaseObjects_Subset</a> conditions
and the objItem's <a href="IDatabaseObject_DistinctValue.htm">IDatabaseObject_DistinctValue</a> value
to create the WHERE clause in the UPDATE statement. Therefore, the combination
of the <a href="IDatabaseObjects_Subset.htm">IDatabaseObjects_Subset</a> and <a href="IDatabaseObject_DistinctValue.htm">IDatabaseObject_DistinctValue</a> 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.</p>
<!-- InstanceEndEditable --><font face="Courier New, Courier, mono">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#f6f6f6"><pre><!-- InstanceBeginEditable name="example" -->
<span class="comment">'<font face="Courier New, Courier, mono">T</font>his is typ<font face="Courier New, Courier, mono">ically </font>how the Object<font face="Courier New, Courier, mono">Save function is used.
</font>'i<font face="Courier New, Courier, mono">.e. in the Product class the </font>following would be used:
</span>
<span class="keyword">Public Sub </span>Save()
<span class="comment">'Save this product to the products table</span>
<font face="Courier New, Courier, mono">DBO</font>.ObjectSave gobjGlobalProdu<font face="Courier New, Courier, mono">ctsInstance</font>, Me<font face="Courier New, Courier, mono">
<span class="keyword">End Sub</span></font>
<!-- InstanceEndEditable --></pre></td>
</tr>
</table>
</font>
<p> </p>
<p align="center"><font size="1">� Hi Integrity Systems 2005. All rights reserved.</font></p>
</body>
<!-- InstanceEnd --></html>