🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.multi-tier
Article #1710

Re: Error "Record modified by another user"

#1710
From: PIQUOT J�r�me
Date: Fri, 13 Aug 1999 00:00
136 lines
4934 bytes
thanks for your reply but i do not perform equlity test. this exception
happens while i call Provider ApplyUpdates.
after the BeforeUpdateRecord event so i cant trace where it happens.

my app is a brief-case multi-tier client/server app  (the server is a MTS
dll) where CDS has data from a (TQuery) QueryCommande that has a detail
table (TTable) TableArticleCommande.

I use TableCommande (TJTableCommande inherited from TTable) to create Key
IDs. it uses the same table that QueryCommande but it is closed after use.

void __fastcall TIAMTSCommande::ProviderCommandeBeforeUpdateRecord(
   TObject *Sender, TDataSet *SourceDS, TClientDataSet *DeltaDS,
   TUpdateKind UpdateKind, bool &Applied)
{
 if (UpdateKind == ukInsert)
 {
  TableCommande->Active = true;
  TField *sfld, *dfld;
  TableCommande->SetKey();
  for (int i=0; i < TableCommande->IndexFieldCount; i++)
  {
   sfld = TableCommande->IndexFields[i];
   dfld = DeltaDS->FindField(sfld->FieldName);
   if (dfld)
    sfld->Value = dfld->Value;
  }
  if (TableCommande->GotoKey())
  {
   TableCommande->Edit();
   TField *sfld, *dfld;
   for (int i=0; i < TableCommande->FieldCount; i++)
   {
    sfld = TableCommande->Fields->Fields[i];
    if (!sfld->ReadOnly)
    {
     dfld = DeltaDS->FindField(sfld->FieldName);
     if (dfld)
      sfld->Value = dfld->Value;
    }
   }
   TableCommande->Post();
  }
  else
  {
   TableCommande->Active = false;
   throw Exception ("Commande non trouv�e");
  }
  Applied = true;
  TableCommande->Active = false;
 }
}

void __fastcall TIAMTSCommande::ProviderCommandeUpdateData(TObject *Sender,
TClientDataSet *DataSet)
{
 TableCommande->Active = true;
 TField *sfld, *dfld;
 int nFields = TableCommande->FieldCount;
 DataSet->First();
 while (!DataSet->Eof)
 {
  if (DataSet->UpdateStatus() == usInserted &&
DataSet->FieldByName("Code")->AsInteger <= 0)
  {
   try{
   TableCommande->Insert();
   for (int i=0; i < nFields; i++)
   {
    sfld = TableCommande->Fields->Fields[i];
    if (!sfld->ReadOnly)
    {
     dfld = DataSet->FindField(sfld->FieldName);
     if (dfld)
      sfld->Value = dfld->Value;
    }
   }
   TableCommande->Post();
   DataSet->Edit();
   DataSet->FieldByName("Code")->Value =
TableCommande->FieldByName("Code")->Value;
   DataSet->Post();}
   catch(...){}
  }
  DataSet->Next();
 }
 TableCommande->Active = false;
}
//--------------------------------------------------------------------------
-


--

-----------------------------------------------------------------
PIQUOT J�r�me
A. WOLFF SA
6, rue de la Gare
67120 ERNOLSHEIM/BRUCHE
FRANCE
e-mail: wolff@media-net.fr
http://www.media-net.fr/wolff
-----------------------------------------------------------------
Jerry Bloomfield (TeamB) <JersWork@wwa.com> a �crit dans le message :
37ba957d.458483384@forums.inprise.com...
> On Thu, 12 Aug 1999 17:55:15 +0200, "PIQUOT J�r�me" <wolff@media-net.fr>
> wrote:
>
> >when i apply updates from TClientDataSet i have an exception raised with
> >this msg:"Record modified by another user".
> >Could someone help to resolve this?
>
> First of all,  are you positive that no one else is modifying your data
> while your program is running?
>
> Having said that,  I have recently responded to several people with the
> same (or similar) error messages.  One thing to consider is that
performing
> equality tests on floating point values is not a wise thing to do.
Realize
> that Date/Time, Currency, and such fields are often stored as floating
> point values on many of the current database formats,  so using any fields
> of that type on an equality test for an update may result in the error you
> are getting if the field suffers from a "rounding error".  Some people can
> solve this by changing their default UpdateMode to something other than
> upWhereAll,  but that may not help you is the field you are changing is
one
> of the fields suffering from the rounding error,  or if it is a key field
> (depending upon your choice for the UpdateMode)...
>
> Jerry Bloomfield (TeamB)
> --
> Jerry Bloomfield                                     JersWork@wwa.com
> Proud Member of Borland's TeamB
> "We'll do anything if you don't pay us."
Technical Details
Message-ID: <7p0kig$h8f4@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <7ouqd6$fi211@forums.borland.com> <37ba957d.458483384@forums.inprise.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: fcd2b,835c276b5b3c4b94
X-Google-Attributes: gidfcd2b,public
From: "PIQUOT J�r�me" <wolff@media-net.fr>
Subject: Re: Error "Record modified by another user"
Date: 1999/08/13
Message-ID: <7p0kig$h8f4@forums.borland.com>
X-Deja-AN: 512182233
References: <7ouqd6$fi211@forums.borland.com> <37ba957d.458483384@forums.inprise.com>
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
Organization: WOLFF SA
X-MSMail-Priority: Normal
Reply-To: "PIQUOT J�r�me" <wolff@media-net.fr>
Newsgroups: borland.public.cppbuilder.database.multi-tier