MyTable - Error trying to edit records

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
pdp
Posts: 2
Joined: Wed 12 Oct 2011 09:36

MyTable - Error trying to edit records

Post by pdp » Wed 12 Oct 2011 09:52

Firstly, let me apologise if this topic has been covered before elsewhere. I have searched but been unable to find information I require.

I am a newcomer to MySQL as I have always found the BDE to do everthing I wanted.

I am attempting to edit and add data to a table but keep getting an 'Update failed. Found 0 records' error when trying to edit a record that should already exist.

Am obviously doing something stupid but need help.

Delphi 2007, Win 7 64-bit

Code fragment:

with MyTable1 do
begin
TableName := 'm10';
SQL.Clear;
Open;
rc := RecordCount;
Last;

if flag or (rc = 0) then
Append
else
Edit;

flag := False;

FieldByName('Date_Time').AsDateTime := dt;
FieldByName('Count').AsInteger := Count[2];
for c := 1 to 32 do
FieldByName('ch'+IntToStr(c)).AsFloat := Average[c];
Post;
Close;
end;

Any help would be appreciated. Thank you in advance.

AndreyZ

Post by AndreyZ » Fri 14 Oct 2011 12:55

Such error occurs when no records were updated on a server. Please try setting the MyTable1.Debug property to True. The Debug property is used to display the exact statement that is being executed, all its parameters' values, and the type of parameters. This will help you to find the reason of this error.

pdp
Posts: 2
Joined: Wed 12 Oct 2011 09:36

Post by pdp » Fri 14 Oct 2011 21:17

Thank you for the reply.

I have managed to fix this - I think - by adding an autoincrementing primary index to the tables in question. The error message no longer occurs.

Due to my inexperience with MySQL I did not think it was needed.
Shows that you learn something new each day.

:oops:

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Mon 17 Oct 2011 16:34

Feel free to contact us if you have any further questions about MyDAC.

Post Reply