Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Record has been changed by another user has no solution

266 views
Skip to first unread message

Santos

unread,
Jun 4, 2001, 4:50:05 PM6/4/01
to

I am developing an application with Midas (socket connections) and there's a problem with some routines that I am not being able to solve, maybe someone can help me.

What I'm doing is very simple.

for each record that is edited I do a Post that is always followed by an ApplyUpdates(-1).
So, at no moment the Delta has more than one record.

The OnReconcileError event handler has the following:

Action:= HandleReconcileError(DataSet,UpdateKind, E);

which is almost always showing me an error that says that the record has been changed by another user.

But that is impossible because I am the only user of the system and even if I refresh the ClientDataSet (close & open)
or restart the application the exception persists being raised.

I found out that if I insert a record and then modify it once or twice it becomes impossible to modify it again because the exception I mentioned never stops being raised even if I go home and come back next day.

I don't know what I am doing wrong.

(Delphi 5, Windows 98, SQL Server 7.0, BDE 5.01)

somebody please help me.

Thanks

Father - Mike Johnson

unread,
Jun 4, 2001, 7:15:18 PM6/4/01
to
Sounds like a server side object is being created, opening the transaction,
and then not closing up completely.. like you commit your transaction, but
you forgot to close your db connection... something along those lines. So
the object holding the record is just hanging around holding on to the
record instead of closing and freeing itself.

Look at your commits and make sure every starttrans has a commit or rollback
and the every database/recordset open has a cooresponding close.

Mike


Santos <dsanto...@hotmail.com> wrote in message
news:3b1bf47d$1_1@dnews...

Patrick Lenz

unread,
Jun 4, 2001, 7:26:46 PM6/4/01
to
there might be a rounding discrepancy between your database and Delphi.
(most common with datetime timestamps)
search on http://Groups.Google.com for 'MIDAS record changed by another
user' for workarounds.
patrick

"Santos" <dsanto...@hotmail.com> wrote in message
news:3b1bf47d$1_1@dnews...
>

David Thomson

unread,
Jun 5, 2001, 6:25:48 AM6/5/01
to
I had a similar problem a while back. The problem is that Delphi is using values to look for a record that don't quite match the record in question. If you're using dates especially, this can cause a problem as
there is often a difference of precision between delphi dates and the dates stored in your database.

If you're using dates in the record then try using the ShortDateFormat (e.g. ShortDateFormat := 'dd/mm/yyyy' ) variable for both your inputs and outputs so that the values for these fields is the same coming out as
it is going in. You might also want to consider the ProviderFlags property of each field in your dataset. Set the pfInkey flag to true for each field that forms the key for that dataset.

Then set the provider's UpdateMode property to UpWhereKeyOnly, meaning that the application should search for the record by its key only.

Then add the following code to the OnBeforePost event handler of the Provider.

procedure DataModule.DataSetBeforePost(
DataSet: TDataSet);
begin
DataSet.FieldByName('DateField').AsString :=formatDateTime('dd/mm/yyyy',DataSet.FieldByName('DateField').AsDateTime);
end;

The data you entered previously in your system may also need to be deleted and re-entered as when the applyupdates method is triggered, it checks each and every record and if one of them doesn't match what you have
in your database then it will throw back a 'Record has been changed by another user'.

I may not have explained this very well, but I hope it will maybe even give you a few ideas.

David

Santos wrote:

--

David Thomson

****************************************************************************
The information in this E-mail is confidential and is intended solely for
the addressee or someone authorised to receive the addressee's E-mail. Any
views or opinions presented are solely those of the author and do not
necessarily represent those of the University of Glasgow. The University
accepts no liability for the content of this e-mail, or the consequences of
any actions taken on the basis of the information provided.
****************************************************************************


Santos

unread,
Jun 5, 2001, 12:25:42 PM6/5/01
to

Your're right David

The problem was the precision of the TDateTime fields as you
and Patrick said.

Now I am doing as you said

DataSet.FieldByName('DateField').AsString :=formatDateTime('dd/mm/yyyy',DataSet.FieldByName('DateField').AsDateTime);

and my application is running smoothly.

I did not change the properties of the TFields and my provider is working with UpdateMode UpWhereAll and I don't feel the necessity of changing it now.

Thank all of you.

0 new messages