Problem with 'Post' in DBNavigator lazarus / 16-Databases ---------------------------------------------------------------------- yurav · 2007-01-31 20:17 I'm make simple project in Lazarus 0.9.20 for work in MySQL 4.0. I drop to form follow componet's: TMySQL40Connection, TSQLTransaction, TSQLQuery, TDatasource, TDBGrid and TDBNavigator. In SQLTransaction set 'Action' property as 'caCommit'. In SQLQuery i write SQL command: 'select * from my_table' and set 'ReadOnly' property as 'False'. After run program i have data from my table in DBGrid, but after change data in table and using DBNavigator button 'Post' i have error 'Operation not allowed, dataset 'SQLQuery1' is not in an edit state'. Where is error? How i can post data to my table? ---------------------------------------------------------------------- carlos_oliveira_10 · 2009-10-11 14:02 Hi, I am creating a form with a dgrid and DBNavigator. When I click 'post' nothing is changed in the DB. what is needed? I have these functions defined: datasource1.autoedit = true dbnavigator.datasource = DataSource1 ---------------------------------------------------------------------- tk · 2009-10-11 16:18 Hi, 0.9.20 is very old version. Pls download a newer one, I recommend the latest snapshot but the official 0.9.28 might work well. If then still in trouble, you can try my TKDBGrid. Regards, Tomas ---------------------------------------------------------------------- LacaK · 2009-10-12 05:38 To realy write data you must: 1. Post 2. ApplyUpdates 3. Commit (AFAIK Action property of TSQLTransaction is not implemented, so it has no effect) ---------------------------------------------------------------------- carlos_oliveira_10 · 2009-10-17 18:45 Hi, I am creating a form with a dgrid and DBNavigator. When I click in 'post' nothing is changed in the DataBase. what is needed? I have these functions defined: datasource1.autoedit = true dbnavigator.datasource = DataSource1 with the last version of lazarus i have the same problems. someone help me? thank you. ---------------------------------------------------------------------- tk · 2009-10-17 21:35 Try something like this to check the updating first: Trans := TSQLTransaction.Create(Self); Trans.DataBase := YourConnection; SQLQuery := TSQLQuery.Create(Self); SQLQuery.DataBase := YourConnection; SQLQuery.ParseSQL = True; SQLQuery.UsePrimaryKeyAsKey := False; SQLQuery.SQL.Add := 'SELECT * FROM [yourtable]'; SQLQuery.Upda]"]>Blockedde := upWhereChanged; SQLQuery.Transaction := Trans; SQLQuery.Open; SQLQuery.Edit; SQLQuery.Fields[0].AsString := 'Modified'; // or the like with your type SQLQuery.Post; SQLQuery.ApplyUpdates; Keep in mind that some things in the fpc database system seem to be very incomplete. E.g. the ODBC seems to support only integer and non- unicode string type for write access (I use it to connect to MSSQL - this way I use connect, read and update). TK ---------------------------------------------------------------------- carlos_oliveira_10 · 2009-10-18 02:34 Hi! Thank you for help but this solution doesn't solve my problem... Do you know another solution? Has anyone ever used the DBNavigator? ---------------------------------------------------------------------- tk · 2009-10-18 09:28 But the database updates with my code? If yes, you just need to adapt the SQLQuery.AfterPost event and call SQLQuery.ApplyUpdates. TK ---------------------------------------------------------------------- carlos_oliveira_10 · 2009-10-18 12:03 Quote from: tk on October 18, 2009, 11:28:09 amBut the database updates with my code? If yes, you just need to adapt the SQLQuery.AfterPost event and call SQLQuery.ApplyUpdates. TK Hi, The DBGrids changed with your code but the database no! Thank you ---------------------------------------------------------------------- tk · 2009-10-18 15:07 Is the AfterPost and thus ApplyUpdates called if you press Post? If yes and still db not updated try that Trans.Commit into AfterPost, after the ApplyUpdates command. This must work then. Code: [Select]procedure TMainForm.MyAfterPost(DataSet: TDataSet); begin   try     SQLQuery.ApplyUpdates;     Trans.Commit;   except     on E: Exception do       MessageBox(Handle, PChar('Problem with updating: ' + E.Message), PChar(Caption), MB_OK);   end; end; ---------------------------------------------------------------------- LacaK · 2009-10-23 12:34 Quote from: tk on October 17, 2009, 11:35:28 pmE.g. the ODBC seems to support only integer and non-unicode string type for write access (I use it to connect to MSSQL - this way I use connect, read and update). in 2.5.x branch of FPC is added support for additional types of parameters ...