How I can insert data in a database by code in SQLite? lazarus / 16-Databases ---------------------------------------------------------------------- kakarotv5 · 2007-11-04 15:46 I use SQLite. I want insert values into the database fields but I do not want use a TDBgrid control or similar Data Controls. I want to insert values by means of code. How I do it? Thanks. ---------------------------------------------------------------------- kakarotv5 · 2007-11-04 22:40 I have found the solution: Code: [Select]  dsTest.ExecSQL('INSERT INTO TableName(Field1,Field2,...,Fieldn) values'+'('''+Edit1.Text+''','''+Edit2.Text+''','''+ ... +Editn.Text+''')');  dsTest.RefetchData; ---------------------------------------------------------------------- windy · 2007-11-05 09:04 just the info I was looking for after using sql prepare statements to use the database name needed, I was then able to use the insert command shown here ---------------------------------------------------------------------- LuizAmérico · 2007-11-08 01:04 You can also do:   dsTest.Append;   dsText.FieldByName('Field1').AsString := Edit1.Text;   dsText.FieldByName('Field2').AsString := Edit2.Text;   etc   dsTest.Post;   ApplyUpdates; Some notes:  - in this way is necessary to have a AutoInc field or the PrimaryKey must be set to the proper field  - ApplyUpdates can be applied later, eg when the form closes etc  - is possible to set SaveOnClose and SaveOnRefetch to true that will call applyupdates in the necessary places