Page 1 of 1

MyTable - Error trying to edit records

Posted: Wed 12 Oct 2011 09:52
by pdp
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.

Posted: Fri 14 Oct 2011 12:55
by AndreyZ
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.

Posted: Fri 14 Oct 2011 21:17
by pdp
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:

Posted: Mon 17 Oct 2011 16:34
by Dimon
Feel free to contact us if you have any further questions about MyDAC.