I guess I asked the wrong question before :'( Pascal databases lazarus / 21-General ---------------------------------------------------------------------- OC DelGuy · 2021-01-07 04:13 Previously I asked about controls to display pascal records.  I thought I needed the controls in  the "Data Controls", "Data Access", and "SQLdb" tabs.  Turns out you need a database program to use them and they seem pretty complex. And, as far as I can gather, the database table seems to be created in the database program and not in the Pascal code! I have an existing database I created with Pascal Types: 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 type  Item = record    Description : String;    Quan : Byte;    Price : Real;  end; var  Inventory : array[1..2000] of Item; How can I display these records in a GUI program? ---------------------------------------------------------------------- speter · 2021-01-07 04:20 Have a look at some of the documents relating to database oriented (lazarus) programming, including https://wiki.freepascal.org/Lazarus_Database_Overview and https://wiki.freepascal.org/SQLdb_Tutorial0  (there are at least 4 tutorials) Quote from: OC DelGuy on January 07, 2021, 05:13:28 amI have an existing database I created with Pascal Types... Can you please explain what you mean by the above!? cheers S. ---------------------------------------------------------------------- lucamar · 2021-01-07 04:51 Quote from: OC DelGuy on January 07, 2021, 05:13:28 amI have an existing database I created with Pascal Types: 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 type  Item = record    Description : String;    Quan : Byte;    Price : Real;  end; var  Inventory : array[1..2000] of Item; How can I display these records in a GUI program? Did you do it with normal, flat-file access? as in: 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 var  MyDatabase: file of Item;{... etc...}  Write(MyDatabase, Inventory[i]);  { and so on } Then you'll have to either move it to a more "formal" database (say, a SQLite one, or even a TBufDataset) or read the data normally and use normal (non-database) controls. This last is not difficult (much less if your data set is really that small): just react to some event (e.g. a key or button press), write or read your "database" and populate some controls with the data. It realy depends on exactly what you want to do: if it's just to show records as in a TDBGrid you could populate a TStringGrid instead, if to edit the data record by record, some TLabels, TEdits and TButtons, and so on. ---------------------------------------------------------------------- PascalDragon · 2021-01-07 08:17 Quote from: OC DelGuy on January 07, 2021, 05:13:28 amHow can I display these records in a GUI program? You could implement something like CSVDataset for your custom database format (the unit is relatively short and should be understandable) and then you can use the database controls without problems. The main “magic” is inside TCSVDataPacketReader.ReadNextRow and TCSVDataPacketReader.LoadFieldDefs. ---------------------------------------------------------------------- MarkMLl · 2021-01-07 10:08 Quote from: PascalDragon on January 07, 2021, 09:17:59 amQuote from: OC DelGuy on January 07, 2021, 05:13:28 amHow can I display these records in a GUI program? You could implement something like CSVDataset for your custom database format (the unit is relatively short and should be understandable) and then you can use the database controls without problems. The main “magic” is inside TCSVDataPacketReader.ReadNextRow and TCSVDataPacketReader.LoadFieldDefs. That could be a fun general-purpose project. I've been working on a parser for a particular type of binary file which I implemented cautiously on a byte-by-byte basis so as to be able to report accurately on unexpected EOF etc., and I'd imagine that something like that could be made into a component with a formatting template or language definition provided at runtime and diagnostics to a stream. MarkMLl ---------------------------------------------------------------------- wp · 2021-01-07 10:08 I guess you are a beginner: you should forget about databases, nothing to get started! You always talk about "displaying" data. Therefore a stringgrid is absolutely sufficient for this purpose. I am attaching a simple demo project which creates some dummy inventory items and displays them in a grid. Try to understand every line of this project, I added lots of comments. Ask what you don't understand. This demo creates the inventory by code. In the next step you should read the inventory from a file. But I thought it is more motivating when the first step gives you something to see.