DB application from Delphi to Lazarus lazarus / 16-Databases ---------------------------------------------------------------------- micheus · 2012-08-08 16:34 I just finished to convert a project from Delphi and now I started testing it - Form by Form (40 form/datamodule). Unfortunately this seem not be so simple. I'm going to use this thread to group the doubts and/or errors I find in this process and I'll appreciate any help. I'm using:  - Lazarus 1.0 RC1 (2012-07-29); FPC 2.6.0; SVN revision 38085; i386-win32/win64  - Native database components (SQLdb palette): TIBConnection/TSQLTransaction/TSQLQuery  - Native dataaware controls ________________________________ 1) TDBLookupComboBox - error: Database not assigned There is one form with five TDBLookupComboBox and all components in this form has the same DataSource (DSParametros). Here is a video for help you see what I'm experiencing: http://vimeo.com/47120143 At design-time I'm able to open the dataset and see the components contents changing correctly (01:00), but at run-time I'm getting that error. If I remove the DataSource property from all TDBLookupComboBox (let it empty), I'm able to see the form working at run-time without any error - but only after I use Run->Clean up build files... (01:45-02:00 - notice that DataSource properties were empty). [Added]: The exception raises for each TDBLookupComboBox I have in the Form - Only when the program is launched from Lazarus. Just now I tried to run the exe file and it's all fine - no exceptions. I have forms with much more than these five components - it would be boring to debug the entire application. Any Idea about what is wrong? Is there a way to define the clean up of the Project pre- compiled/compiled files as default? TIA Micheus ---------------------------------------------------------------------- taazz · 2012-08-08 17:14 the debugger stops on all exception raised by the application. Some components though handle some of this exceptions internally so they never surface in your code or the application it self when it is executed outside the debugger. I would suggest to add the specific exception to the ignore list. ---------------------------------------------------------------------- micheus · 2012-08-08 17:24 That's bad news Thank you for your suggestion taazz. ________________________________ 2) TDBImage - Stream read error In this form there is also a TDBImage where a small JPG file stored in the database is shown. This exception is true - it happens inside and outside Lazarus. I have not problem before in Delphi. So, isn't this componente able to process jpg data? ---------------------------------------------------------------------- taazz · 2012-08-09 08:58 Quote from: micheus on August 08, 2012, 07:24:20 pmThat's bad news Thank you for your suggestion taazz. ________________________________ 2) TDBImage - Stream read error In this form there is also a TDBImage where a small JPG file stored in the database is shown. This exception is true - it happens inside and outside Lazarus. I have not problem before in Delphi. So, isn't this componente able to process jpg data? Delphi TDBImage has some extra code that saves the type of the image infront of the image stream on the other hand lazarus expects a clean stream and looks for hints in the image data them self to find out the type with out requiring the those extract bytes of info. This creates a small incompatibility between the two. As I see it you should try to import an image in a new record using lazarus and see if that creates any problems viewing it with TDBImage and if it works then you need to work a way to allow the TDBImage to load images imported from a delphi application. There are a lot of ways to do it, raging from a custom TDBImage that uses the extract info if exist and reverts to what ever lazarus has to offer if not, to custom loading and saving procedure that will by pass the existing mechanism all together, its up to you actually. ---------------------------------------------------------------------- LuizAmérico · 2012-08-09 15:47 About the DBLookup error: This occurs because the DBLookupCombobox tries to open the dataset automatically leading to such errors. See http://lists.lazarus.freepas cal.org/pipermail/lazarus/2012-July/074682.html for more info I plan to remove this feature since leads to unpredicable errors/problems like you are seeing. But it will be avaliable in post 1.0 only due to compatibility ---------------------------------------------------------------------- Knipfty · 2012-08-09 16:13 Luiz, Couldn't you add another property to the DBLookupComboBox to allow the programmer to open the table?  I think it would look cleaner since you would be activating the DBLookUpComboBox and not the table (or query). Knipfty ---------------------------------------------------------------------- taazz · 2012-08-09 16:26 Quote from: Knipfty on August 09, 2012, 06:13:11 pmLuiz, Couldn't you add another property to the DBLookupComboBox to allow the programmer to open the table?  I think it would look cleaner since you would be activating the DBLookUpComboBox and not the table (or query). Knipfty If it were me I wouldn't allow the GUI controls to automatically open the underline dataset controls but I would have visual representation of the dataset status eg if the datasource is assigned and the dataset is closed then the dblookupcombobox would be disabled (grayed out). Also some kind of customizable visual representation of the fields and datasets status would be desirable like color of the combobox when the field is read only, required, etc. ---------------------------------------------------------------------- teos · 2012-08-20 14:30 Luiz, I would not give up automatically opening a database/dataset. The problem mentioned is most likely caused by a conversion in wich the "database" property was not set. If you remove that, there will be much more problems: everyone using the component with a database assigned will run into the situation that a table is not opened so the dbLookupcombobox does not show data. Opening tables/queries at runtime is the same worthless approach that other programming languages have: assign and open everything in code and after a while you spend loads of time figuring out wether properties of your components are set or not.