Run SqlQuery1 using button lazarus / 16-Databases ---------------------------------------------------------------------- Bui Thiet · 2020-01-31 15:21 How to Run SqlQuery1 using button ---------------------------------------------------------------------- JanRoza · 2020-01-31 16:30 Depends on what you want to do when the button is clicked. If you want to make another selection from a table code could look like this: 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 button1.clickvar  strSQL: String;begin  strSQL := 'SELECT * FROM ';  SQLQuery1.Active := false;  SQLQuery1.SQL.Text := strSQL;  SQLQuery1.Active := true;end; Replace by the real name of the table you want to use. ---------------------------------------------------------------------- Bui Thiet · 2020-02-01 15:12 Thanks JanRoza and it worked fine, it was great ---------------------------------------------------------------------- Bui Thiet · 2020-02-01 15:59 How to compare values ​​in Edit1 with values ​​with Date Columns of type Date in Database. I want to sum by condition. Sincerely thank you, hope you will help me. ---------------------------------------------------------------------- JanRoza · 2020-02-01 23:44 How about: 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 // Check edit1 against a database dateif StrToDate(edit1.Text) <= SQLQuery1.FieldByName('').asStringthen ….......;  Search this forum for more info on working with databases, especially wiki pages. You can learn a lot from them. ---------------------------------------------------------------------- Bui Thiet · 2020-02-03 14:20 Thank you for your help, I have another problem, I want to create 'Save'update'Delete,', 'I'm a new person so my ability is still limited. Oh, any help would mean a lot to me. Thanks very much. ---------------------------------------------------------------------- rvk · 2020-02-03 15:25 A few remarks... An UPDATE SQL statement doesn't have := as assignment. So it is Code: SQL  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i UPDATE Danhmuc SET St=:Stt, etc Note that the :Stt is in place of the parameter (that's what the : prefix is for) and there is no : before the = But... you don't need all that. If all is correct, the SQLQuery1.DeleteSQL and SQLQuery1.InsertSQL should already be set automatically. So you can just do the following. (and because you are using TDBEdits you don't need to use ParamByName etc.) 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 Tfrmdanhmuc.ButtonDeleteClick(Sender: TObject);begin  SQLQuery1.Delete;end; procedure Tfrmdanhmuc.ButtonDeleteClick(Sender: TObject);begin  SQLQuery1.Insert;  // a new row is inserted  // everything you change now in the DBGrid will be changed  // and you need to press a Update-button to really post the changesend; procedure Tfrmdanhmuc.ButtonDeleteClick(Sender: TObject);begin  SQLQuery1.Post;  SQLQuery1.ApplyUpdates;end; ---------------------------------------------------------------------- JanRoza · 2020-02-03 15:54 Bui Thiet, See this sample project https://www.silentwings.nl/data/Kaartenbak.zip which is a simple cardfile system using SQLite that I used in a magazine tutorial some years ago. Comments are in Dutch I'm afraid but It might help you a bit anyway. ---------------------------------------------------------------------- Bui Thiet · 2020-02-04 05:05 Thank you all, I will do it now.