Help:the opreation with a SQLite3Dataset lazarus / 16-Databases ---------------------------------------------------------------------- Enigma Huang · 2013-02-23 08:39 I'm a beginner on Database, and I've got some trouble with my SQLite3Dataset, please help me! For example, I have a simple table that only with two field "Name" and "Email" which are all ftString. And now the SQLite3Dataset(for convenience I will use SQLite3 in the below) is opened. And I want to operate after located it like  Code: [Select]  AimID:=StrToInt(Edit1.Text);   whileSQLite3.RecNoAimID do   begin     SQLite3.Prior;     SQLite3.CursorPosChanged;   end;   with SQLite3 do   begin     FieldByName('Name').AsString:=Edit2.Text;     FieldByName('EMail').AsString:=Edit2.Text;   end; But lazarus tells me that the "SQLite3 is not in a edit or insert state". How can I solve this? ---------------------------------------------------------------------- taazz · 2013-02-23 10:31 with SQLite3 do   begin     Edit;     FieldByName('Name').AsString:=Edit2.Text;     FieldByName('EMail').AsString:=Edit2.Text;   end; ---------------------------------------------------------------------- Enigma Huang · 2013-02-23 10:53 Quote from: taazz on February 23, 2013, 11:31:58 am  with SQLite3 do   begin     Edit;     FieldByName('Name').AsString:=Edit2.Text;     FieldByName('EMail').AsString:=Edit2.Text;   end; Thanks a lot ^_^. By the way, do I need to do any other operation after edit? I mean that whether it will meet a error or exception if I read or add records or execute other operations just after the edit? ---------------------------------------------------------------------- taazz · 2013-02-23 13:12 after you finish editing the record's data you have to call post to save the data, and depending the design of SQLite3dataset object you might also need to call ApplyUpdates to persist the data on the datafile. I do not use sqlite and although I think is a superb peace of code the lack of proper data types and a few other things makes me keep my distance, that's why I can't tell you for sure what is required. ---------------------------------------------------------------------- snorkel · 2013-03-07 16:06 right after the edit you need to post the data, then in the after post event of the dataset you need to call applyupdates and then (whatever you called your transaction).commitretaining. You should then also share the event with the after delete event as well. ---------------------------------------------------------------------- snorkel · 2013-03-07 16:12 if your looping through a dataset you should do it like this: Code: [Select]while not mydataset.eof do begin         if mydataset.fieldbyname('myfieldname').asstring = 'bbdfdf' then            begin                     //do something            end;        mydataset.next; end; Also if you have a DBgrid attached to the dataset you should to a beginupdate before you start the loop and a endupdate when you are done so the dbgrid does not update/scroll while you process the dataset.