SQLite3 [Newbie Question] lazarus / 16-Databases ---------------------------------------------------------------------- arwen · 2020-05-11 07:35 Good morning everyone. I am developing a small application on Lazarus 2.0.8 using sqlite and I need some information. I am using these components: TSQLite3Connection TSQLQuery TSQLTransaction TDataSource TDBGrid TDBNavigator 1 - If in the Grid I create a new record but do not fill in at least one column the post is not successful and the system signals me "No insert query specified and failed to generate one. (No field found for insert or update-statement found) " How to handle this situation? 2 - In a table with a UNIQUE integer field, if I try to insert a record with a duplicate field it is not inserted (correct reaction) but how do I manage the situation and reset the query or transaction without having to close the form? In practice how do I handle the error cleanly? Thanks in advance ---------------------------------------------------------------------- LacaK · 2020-05-11 10:04 1: IMO in this case you must manually define InsertSQL property of TSQLQuery object 2: Try, look at OnUpdateError event handler of TSQLQuery object More info you can found at https://wiki.freepascal.org/Working_With_TSQLQuery ---------------------------------------------------------------------- Jurassic Pork · 2020-05-11 10:40 hello, Quote from: arwen on May 11, 2020, 09:35:39 amGood morning everyone. I am developing a small application on Lazarus 2.0.8 using sqlite and I need some information. I am using these components: TSQLite3Connection TSQLQuery TSQLTransaction TDataSource TDBGrid TDBNavigator coming with Lazarus > 1.8,  have a look to the example with all these components :   Lazarus/examples/database/image_mushrooms Features: - Use SqlDb and lazreport components. - Sqlite3 or Firebird embedded database DeadlyMushrooms with 5 mushrooms. Friendly, J.P ---------------------------------------------------------------------- QEnnay · 2020-05-11 15:21 Quote from: arwen on May 11, 2020, 09:35:39 amI am developing a small application on Lazarus 2.0.8 using sqlite and I need some information. It would help greatly if you would include the code you are using to insert the records. You are telling us the color of your car and asking for help on why it doesn't start. SQlit3 works fine, so it can only be the code you are using. I suggest you also spend some time with YT tutorials. ---------------------------------------------------------------------- arwen · 2020-05-11 15:58 This is the code I'm working on ---------------------------------------------------------------------- arwen · 2020-05-13 10:26 I should have solved it. In InsertSQL added : INSERT OR ABORT INTO cod_a (cod_a,desc_cod_a) VALUES(:cod_a,:desc_cod_a); Implemented OnPostError and OnUpdateError event  : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm2.SQLQueryCodAPostError(DataSet: TDataSet; E: EDatabaseError;  var DataAction: TDataAction);begin  MessageDlg('Errore sul DataBase per POST',  E.Message+LineEnding+LineEnding+  'VERIFICARE E CORREGGERE I DATI INSERITI',mtError,[MbOK],0); end; procedure TForm2.SQLQueryCodAUpdateError(Sender: TObject;  DataSet: TCustomBufDataset; E: EUpdateError; UpdateKind: TUpdateKind;  var Response: TResolverResponse);begin  MessageDlg('Errore sul DataBase per UPDATE',  E.Message+LineEnding+LineEnding+  'VERIFICARE E CORREGGERE I DATI INSERITI',mtError,[MbOK],0);end;  Quote from: LacaK on May 11, 2020, 12:04:34 pm1: IMO in this case you must manually define InsertSQL property of TSQLQuery object 2: Try, look at OnUpdateError event handler of TSQLQuery object More info you can found at https://wiki.freepascal.org/Working_With_TSQLQuery