MYSQL Frustration lazarus / 16-Databases ---------------------------------------------------------------------- nicod98 · 2015-09-19 12:26 A long time ago I used to program in Delphi (1/2/3) but after more than a decade of something else I decided return to Pascal for some private projects, and found Lazarus. I manage to make quite a nice application, but somehow I NEVER seem to be able to update the MySQL Backend database. dbGrids are working fine, but changes are never written to the database. After more than a hundred hours of searching and trying (and reading the wiki over and over...), I am convinced that something is wrong with how I use the "transaction" part of it. Every "solution" to the mysql-problem I found is doing everything in code, which defeats the purpose of the IDE in my eyes, and therefore is NOT an option. Is there anyone around here that can give a simple step by step, of a single form application with 1 table with mysql and 1 dbGrid that really works??? ---------------------------------------------------------------------- rvk · 2015-09-19 12:51 Quote from: nicod98 on September 19, 2015, 02:26:08 pmAfter more than a hundred hours of searching and trying (and reading the wiki over and over...), I am convinced that something is wrong with how I use the "transaction" part of it. Every "solution" to the mysql-problem I found is doing everything in code, which defeats the purpose of the IDE in my eyes, and therefore is NOT an option. You always need to do "some" coding in events. Even in Delphi. If you show us some code of what you have under your "Save definite data to database"-button we can see why it's not saving for you. I take it (if you already went through the wiki) you have something like this: Code: [Select]procedure TForm1.ApplyAllDataToDatabaseButton1Click(Sender: TObject); begin   SQLQuery1.ApplyUpdates;   SQLTransaction1.Commit; // or CommitRetaining depending on your needs end; (You could also do this in a OnClose-event.) Without seeing what you do to actually apply the data to the database, we can't help you much. (Note: ApplyUpdates is something you need to do manually in code in Lazarus/FPC. Delphi does this automatically for you but FPC does not.) ---------------------------------------------------------------------- marcov · 2015-09-19 13:19 It would be more correct to say sqldb does. Afaik ZEOS under FPC doesn't require it either. ---------------------------------------------------------------------- mse · 2015-09-19 14:38 AFAIK SqlDB now supports it too. Wit MSEgui it is also possible to make simple SQL applications without code, an example is here: https://gitlab.com/mseuniverse/mseuniverse/tree/master/samples/db/simp lemysql From README.TXT: Code: [Select]How to make a simple MySQL MSEgui application without code: Place a tmysqlconnection component from tab DB on the form, name it "conn". Place a tmsesqltransaction component from tab DB on the form, name it "trans". In "conn.transaction" select "trans". Place a tmsesqlquery component from tab DB on the form, name it "query". In "query.database" select "conn". In "query.SQL" enter "select * from table1". In "conn" enter the values for "DatabaseName", "HostName", "UserName" and  "Password". If the database is utf-8 encoded set "conn.controller.options.dbo_utf8"  to "true". Place a tmsedatasource component from tab DB on the form, name it "dataso". In "dataso.dataset" select "query". Place a tdbnavigator component from tab DB on the form, name it "dbnav". In "dbnav.datasource" select dataso. Place a tdbstringgrid component from tab DB on the form, name it "grid". In "grid.datalink.datasource" select "dataso". Set "grid.options.dsgo_autofields to "true". Set "query.active" to "true". The database should contain a table "table1" with an autoinc primary key field. ---------------------------------------------------------------------- miab3 · 2015-09-19 14:46 @ nicod98 In ZEOS default is autocommit. Here, well-functioning version 7.2 svn 3642: http://svn.code.sf.net/p/zeoslib/code-0/branches/testing-7.2/ In addition ZEOS works identically in Delphi(7-XE10) and Lazarus. Michal ---------------------------------------------------------------------- LacaK · 2015-09-20 17:10 Quote from: mse on September 19, 2015, 04:38:59 pmAFAIK SqlDB now supports it too. Yes incomming FPC 3.0 has introduced: TSQLQuery.Options property, where you can set: sqoAutoApplyUpdates and/or sqoAutoCommit and sqlDB will do work for you.