Page 1 of 1
message: 0 record(s) updated. Only one record should have been updated
Posted: 29.01.2017, 19:54
by Cuci
Hello, I know, that this topic has been used not long before, but in my case, this message comes every time when I want to change a record the second time and I have to quit the program.
Is there a possibility to prevent this behaviour?
Re: message: 0 record(s) updated. Only one record should have been updated
Posted: 30.01.2017, 09:18
by marsupilami
Hello Cuci,
it seems like you are using WhereMode wmWhereAll and your record got changed by some other process or transaction - or even another query in your project? If you are sure this is not because of your application logic, you can chenge the WhereMode to wmWhereKeyOnly. Usually the message then disappears as long as your primary key is stable. Please note that you will not get any notice then if another process changes the record while you are working on it.
With best rgards,
Jan
Re: message: 0 record(s) updated. Only one record should have been updated
Posted: 01.02.2017, 22:00
by Cuci
Hello Jan,
i would say you, that I made a little step. You must know, that I want to remake my Delphi 2010-progam with Lazarus. So I take the code from my program and try step by step to go forward. I get now no more this error - it was the code which was not compatible. But there is another thing which doesn't work without error. I want to copy the value of a field from one table to another. Here is my code:
_______________________________________________________________
procedure Tbody.DBNavigator_MieterBeforeAction(Sender: TObject;
Button: TDBNavButtonType);
begin
DBNavigatorMieterPost;
end;
procedure TBody.DBNavigatorMieterPost;
var nam, vorn, date, anre : String;
{ BM_Mieter : TBookmark; }
begin
DaMod1.ZQy_mieter.Open;
DaMod1.ZQy_mieter.Edit;
DaMod1.ZQy_anrede.Open;
DaMod1.ZQy_anrede.Edit;
nam := DaMod1.ZQy_mieterName.Value; { Datenfeld NameVorname automatisch füllen }
vorn := DaMod1.ZQy_mieterVorname.Value;
DaMod1.ZQy_mieterNameVorname.Value := nam + vorn;
date := FormatDateTime('dd.mm.yyyy', now); { Datenfeld DATUM automatisch füllen }
DaMod1.ZQy_mieterDatum.Value := date;
The code of the following two lines doesn't work but I get no error
anre := DaMod1.ZQy_anredeGeschlec.Value; { Datenfeld Geschlecht aus Tabelle Anrede }
DaMod1.ZQy_mieterGeschl.Value := anre; {in Tabelle Mieter kopieren }
end;
May be you find a bad code . . .
Re: message: 0 record(s) updated. Only one record should have been updated
Posted: 02.02.2017, 08:52
by marsupilami
Hello Cuci,
duh - in that case it is hard to tell, what is going on. What happens when you step through the program with the debugger? Does anre have the correct value before it is assigned to DaMod1.ZQy_mieterGeschl ? And does DaMod1.ZQy_mieterGeschl still have the correct value before everything gets posted to the database?
I usually tend to use the type safe methods like .AsString or .AsDate instead of the generic .Value because .Value will return a variant. If ZQy_anredeGeschlec is null for some reason the line "anre := DaMod1.ZQy_anredeGeschlec.Value" might prodce an exception.
With best regards,
Jan
Re: message: 0 record(s) updated. Only one record should have been updated
Posted: 02.02.2017, 11:00
by Cuci
Hello Jan,
you gave me some good ideas, thank you for helping. I was still searching yesterday evening and I know now the corner, where to turn the screw. Therefore I will close this thread. Bye.