Strange problem with edit of table

Forum related to SQLite

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
Rogier21
Fresh Boarder
Fresh Boarder
Posts: 11
Joined: 22.11.2006, 19:32

Strange problem with edit of table

Post 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?
btrewern
Expert Boarder
Expert Boarder
Posts: 193
Joined: 06.10.2005, 18:51

Post 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
Rogier21
Fresh Boarder
Fresh Boarder
Posts: 11
Joined: 22.11.2006, 19:32

Post 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!
Post Reply