Avectra.netForum.Data.FacadeClass.ClearValues

Clears the value of every Field in every DataClass of the Facade Object.

Parameters

None

Returns

None

Usage and Examples

OleDbConnection oConn = DataUtils.GetConnection();
OleDbTransaction oTrans= oConn.BeginTransaction();
FacadeClass oF = DataUtils.InstantiateFacadeObject("Individual");
oF.CurrentKey = "3781E3A3-04A4-40F4-996E-DAA11F322056";
oF.SelectByKey(oConn, oTrans);
oF.SetValue("ind_last_name", "Jones");
ErrorClass oEr = oF.Update(oConn, oTrans);
 
// Load up a different Individual
// First, clear out all the values:
oF.ClearValues();
oEr = new ErrorClass();
 
// The customer key of a different customer:
oF.CurrentKey = "1CB7C8D5-A15C-4E5A-8612-9B3EFD4C41A4";
oF.SelectByKey(oConn, oTrans);
oF.SetValue("ind_last_name", "Smith");
oEr = oF.Update(oConn, oTrans);
   

If you are ever looping through multiple records, it is better to instantiate the Object before the loop and then clear the values after each loop by calling ClearValues. Instantiating new Facade objects consumes a lot of resource and should be minimized where possible.

Wrong:

for(int i=0; i<Count;i++)
{
OleDbConnection oConn = DataUtils.GetConnection();
OleDbTransaction oTrans= oConn.BeginTransaction();
FacadeClass oF = DataUtils.InstantiateFacadeObject("Individual");
oF.CurrentKey = "3781E3A3-04A4-40F4-996E-DAA11F322056";
oF.SelectByKey(oConn, oTrans);
oF.SetValue("ind_last_name", newLastName);
ErrorClass oEr = oF.Update(oConn, oTrans);
}
   

Right:

OleDbConnection oConn = DataUtils.GetConnection();
OleDbTransaction oTrans= oConn.BeginTransaction();
FacadeClass oF = DataUtils.InstantiateFacadeObject("Individual");
ErrorClass oEr = new ErrorClass();
for(int i=0; i<Count;i++)
{
oF.CurrentKey = "3781E3A3-04A4-40F4-996E-DAA11F322056";
oF.SelectByKey(oConn, oTrans);
oF.SetValue("ind_last_name", newLastName);
oEr = oF.Update(oConn, oTrans);
oF.ClearValues();
}