Page 1 of 1

Strange problem with edit of table

Posted: 05.07.2008, 12:50
by Rogier21
I have a TZTable connected to a SQLite table, which I want to update.

I do this with:

Code: Select all

Table.Edit;
Table.FieldByName('Name').AsString := 'test';
Table.FieldByName('Address').AsString := Edit2.text;
Table.Post;
Should be ok right?

Well if I refresh the table right after this, ALL the records have been updated with "test" as the Name field!

Strange thing, if I leave Edit2.text empty, all records remain unchanged! So only if I actually change the data of the selected record, it will update all records with that field!

Bug or am I crazy?

Posted: 05.07.2008, 21:03
by btrewern
If I had to guess I'd say your table doesn't have a primary key. Try adding one to see if that fixes this.

Ben

Posted: 05.07.2008, 21:22
by Rogier21
I monitored the output with the Monitor component, and you are right, there was no index specified:
UPDATE table SET field = 'value';
No where clause included.

Thanks anyway!