Zeos tutorial: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | 1 | # Overview | |
| 2 | 2 | ||
| 3 | 3 | This tutorial is about getting, installing and using [Zeoslib](http://zeos.firmos.at/portal.php) with [[Glossary|Lazarus]] and [[Glossary|FPC]]. | |
| 4 | 4 | ||
| 5 | 5 | # Getting Zeos | |
| 6 | 6 | ||
| 7 | 7 | Zeos has recently been ported to [[Glossary|Lazarus]] and there are no releases yet that officially support it but you can easily get it from SVN if you follow these steps: | |
| 8 | 8 | ||
| 9 | 9 | ## SVN | |
| 10 | 10 | ||
| 11 | 11 | ### Windows | |
| 12 | 12 | ||
| 13 | 13 | - get a SVN client [TortoiseSVN](http://tortoisesvn.tigris.org) and install | |
| 14 | 14 | - see [Getting Started with TortoiseSVN](http://tortoisesvn.net/docs/release/TortoiseSVN_en/help-onepage.html#tsvn-dug-general) | |
| 15 | 15 | - do Checkout from Windows Explorer: <http://svn.code.sf.net/p/zeoslib/code-0/trunk> | |
| 16 | 16 | ||
| 17 | 17 | ### Linux/BSD | |
| 18 | 18 | ||
| 19 | 19 | - [[Portal:FreeBSD|FreeBSD]] comes with *'svnlite* (an svn client) preinstalled | |
| 20 | 20 | - get an SVN client (esvn, kdesvn, etc.) | |
| 21 | 21 | - create zeosdbo directory, go in that directory and do | |
| 22 | 22 | - svn checkout <http://svn.code.sf.net/p/zeoslib/code-0/trunk> | |
| 23 | 23 | ||
| 24 | 24 | ## ZIP | |
| 25 | 25 | ||
| 26 | 26 | You can download the latest version as a ZIP file from sourceforge.net: | |
| 27 | 27 | ||
| 28 | 28 | - [<http://sourceforge.net/projects/zeoslib/>](http://sourceforge.net/projects/zeoslib/) | |
| 29 | 29 | ||
| 30 | 30 | # Installing the components | |
| 31 | 31 | ||
| 32 | 32 | This is a tricky part so you should have a little patience and read this part carefully. | |
| 33 | 33 | ||
| 34 | 34 | - Make sure you have the latest [Lazarus snapshot](http://www.de.freepascal.org/lazarus/) and the at least FPC 2.0.3 not older than 6th March 2006. | |
| 35 | 35 | - Start one instance of Lazarus. | |
| 36 | 36 | ||
| 37 | 37 | 1. Use **Components/Open Package File(.lpk)** from the main menu. | |
| 38 | 38 | 2. Go to **zeosdbo_rework\packages\lazarus\** and open **zcomponent.lpk**. Note: Starting with Zeos 7.3 / 8.0 Zeos has a new zcomponentdesign package for Lazarus. Please use this package on these versions. | |
| 39 | 39 | 3. Press **\[Compile\]** only if you don't want to install the components into the IDE | |
| 40 | 40 | 4. Press **\[Install\]** | |
| 41 | 41 | 5. You are asked if you want to recompile Lazarus. | |
| 42 | 42 | ||
| 43 | 43 | - Answer **\[Yes\]** this time. | |
| 44 | 44 | - Wait until compilation ends, Lazarus should restart itself after that. | |
| 45 | 45 | - If all is ok you should now be able to see the **\[Zeos Access\]** tab in the Component Palette. | |
| 46 | 46 | ||
| 47 | 47 |  | |
| 48 | 48 | ||
| 49 | 49 | If you receive the error "Cannot find unit ZClasses" or something similar, then you need to carefully check the case of the filenames in your Zeos source distribution. | |
| 50 | 50 | ||
| 51 | 51 | - Even if the cases match exactly, the autogenerated package source file can generate the wrong case name in the uses clause (Lazarus 0.9.18), i.e.: | |
| 52 | 52 | ||
| 53 | 53 | ``` pascal | |
| 54 | 54 | { This file was automatically created by Lazarus. Do not edit! | |
| 55 | 55 | This source is only used to compile and install the package. | |
| 56 | 56 | } | |
| 57 | 57 | unit Zcore; | |
| 58 | 58 | interface | |
| 59 | 59 | uses | |
| 60 | 60 | Zclasses, Zcollections, Zcompatibility, Zexprparser, Zexprtoken, Zexpression, | |
| 61 | 61 | Zfunctions, Zmatchpattern, Zmessages, Zsysutils, Ztokenizer, Zvariables, | |
| 62 | 62 | Zvariant; | |
| 63 | 63 | implementation | |
| 64 | 64 | end. | |
| 65 | 65 | ``` | |
| 66 | 66 | ||
| 67 | 67 | - Notice that Lazarus has named the unit ZClasses Zclasses, resulting in a naming conflict. Presumably this is a bug in Lazarus, not the Zeos packages. One way around this is to rename all the zeos source files to lowercase. Trawl through each subdirectory under src/ and execute this command in a bash window: | |
| 68 | 68 | ||
| 69 | - | ||
| 69 | + | ```text | |
| 70 | + | rename -v 'y/A-Z/a-z/' * | |
| 71 | + | ``` | |
| 70 | 72 | ||
| 71 | 73 | - Then, in Lazarus, reopen the package (.lpk) and fix the filename cases by clicking on "More..."/"Fix Files Case" | |
| 72 | 74 | - The package should compile now. | |
| 73 | 75 | ||
| 74 | 76 | # Installing Zeos components in MSEide | |
| 75 | 77 | ||
| 76 | 78 | In order to install the Zeos components: | |
| 77 | 79 | ||
| 78 | 80 | - add the path to the Zeos source to 'Project'-'Options'-'Make'-'Directories' | |
| 79 | 81 | - and compile the IDE with **-dmse_with_zeoslib -dMSEgui**. | |
| 80 | 82 | - There is a predefined IDE project **apps/ide/mseide_zeos.prj**, update 'Project'- 'Options'-'Macros' according to your installation. | |
| 81 | 83 | - A simple demo is in [mseuniverse](https://github.com/mse-org/mseuniverse/tree/main/samples/db/zeos). | |
| 82 | 84 | ||
| 83 | 85 | # Make your first Zeos application | |
| 84 | 86 | ||
| 85 | 87 | - Drop a **ZConnection**. | |
| 86 | 88 | - Set your User, Password, Host, Port and Protocol (and any other params if needed). | |
| 87 | 89 | - Set Connected to True. | |
| 88 | 90 | ||
| 89 | 91 | - Drop a **ZQuery** (do not mistake with ZReadOnlyQuery). | |
| 90 | 92 | - Set the Connection to your active ZConnection. | |
| 91 | 93 | - Set the Sql property to something like **SELECT * FROM MyTable** | |
| 92 | 94 | - Set Active to True. | |
| 93 | 95 | ||
| 94 | 96 | - Drop a **DataSource** from the **\[Data Access\]** tab. | |
| 95 | 97 | - Set the DataSet to your active ZQuery. | |
| 96 | 98 | ||
| 97 | 99 | - Drop a **DBGrid** from the **\[Data Controls\]** tab. | |
| 98 | 100 | - Set the Datasource to your DataSource. | |
| 99 | 101 | - If all is ok you should now be able to see the records from your table. | |
| 100 | 102 | ||
| 101 | 103 | # Possible Bugs and Issues | |
| 102 | 104 | ||
| 103 | 105 | - I have noticed that sometimes when building Lazarus it cannot find some Zeos files, as a quick workaround try this: | |
| 104 | 106 | - Use **Components/Package Graph** from the main menu. | |
| 105 | 107 | - Open the **ZComponent** package. | |
| 106 | 108 | - Right Click on the **Files** item in the list. | |
| 107 | 109 | - Choose **\[Recompile all required\]**. | |
| 108 | 110 | - When asked "Re-Compile this and all required packages?" answer **\[Yes\]**. | |
| 109 | 111 | - Recompile Lazarus normally (with packages).\ | |
| 110 | 112 | \ | |
| 111 | 113 | ||
| 112 | 114 | # See also | |
| 113 | 115 | ||
| 114 | 116 | - [Forum for ZeosLib](http://zeoslib.sourceforge.net/index.php) | |
| 115 | 117 | - [[ZeosDBO]] | |
| 116 | 118 | - [Tutorial Lazarus/Zeos/Firebird (Windows)](https://lazarus.intern.es/tutorial_firebird_lazarus_zeos_2.html) German/Parts in English [download site](https://lazarus.intern.es/download_tutorials_lazarus_zeos_firebird.html) | |
| 117 | 119 | ||
| 118 | 120 | --- | |
| 119 | 121 | *From the Free Pascal wiki, page "Zeos tutorial", as it stood on 2022-03-28 after a change by Marsupilami, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* |
