back visibility lazarus / 16-Databases ---------------------------------------------------------------------- amedeo · 2022-03-27 08:25 Hy people I have a question to change my application. My application have a Main form from where I launch child forms by FormXxx.Show. In every child form there are declaration of Database (SQLite3), Transaction, Tabs e Datasets. Is it possible to declare Database information in the  Main form and use its in the child forms? I saw that calling Database function from a child form the Database is seen but not usable. This is because my ignorance or is it a limit? Thanks Amedeo ---------------------------------------------------------------------- Bart · 2022-03-27 08:30 Use a separate datamodule perhaps? Bart ---------------------------------------------------------------------- amedeo · 2022-03-27 09:35 Not, I do not use data-module just Tabs and Datasets ---------------------------------------------------------------------- amedeo · 2022-03-27 09:41 ... sorry ... I use Tabs and Query with Data-source ---------------------------------------------------------------------- wp · 2022-03-27 09:42 Quote from: amedeo on March 27, 2022, 10:25:09 amIs it possible to declare Database information in the  Main form and use its in the child forms? Never do this. Because it will create a circular dependence between the child forms and the main form: the main form needs to know the child forms in order to open them, and the child forms need the main form in order to access the datasets. Although Pascal can handle this if done properly, it is a very bad idea because you no longer can test the individual forms independently of the entire application. I recently wanted to convert a large Delphi application with about 50 forms to Lazarus; since each form depended on the main form the conversion can only be tested when everything is completed - I finally gave up. Do what Bart told you: Add a datamodule to the project and put all the database components (connections, queries, datsets) on it. You can also put the TDataSource on it, but sometimes I find it more advantageous to have on the forms which need it. ---------------------------------------------------------------------- jcmontherock · 2022-03-27 09:58 You can create a common unit containing all the SQLite access. This unit could be included in all the forms accessing SQLite. That's not follow the OOP rules, but it works fine. I did it for an application multi forms with MySQL successfully. You have to play with some pointers between units. ---------------------------------------------------------------------- amedeo · 2022-03-28 09:57 Thanks now I have a lot of mater to think about. ZEN meditation needs. Amedeo