Zeos tutorial: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: Zeos tutorial
| Old | New | Line | |
|---|---|---|---|
| 1 | + | # Overview | |
| 2 | + | ||
| 3 | + | This tutorial is about getting, installing and using [Zeoslib](http://zeos.firmos.at/portal.php) with [[Glossary|Lazarus]] and [[Glossary|FPC]]. | |
| 4 | + | ||
| 5 | + | # Getting Zeos | |
| 6 | + | ||
| 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 | + | ||
| 9 | + | ## SVN | |
| 10 | + | ||
| 11 | + | ### Windows | |
| 12 | + | ||
| 13 | + | - get a SVN client [TortoiseSVN](http://tortoisesvn.tigris.org) and install | |
| 14 | + | - see [Getting Started with TortoiseSVN](http://tortoisesvn.net/docs/release/TortoiseSVN_en/help-onepage.html#tsvn-dug-general) | |
| 15 | + | - do Checkout from Windows Explorer: <http://svn.code.sf.net/p/zeoslib/code-0/trunk> | |
| 16 | + | ||
| 17 | + | ### Linux/BSD | |
| 18 | + | ||
| 19 | + | - [[Portal:FreeBSD|FreeBSD]] comes with *'svnlite* (an svn client) preinstalled | |
| 20 | + | - get an SVN client (esvn, kdesvn, etc.) | |
| 21 | + | - create zeosdbo directory, go in that directory and do | |
| 22 | + | - svn checkout <http://svn.code.sf.net/p/zeoslib/code-0/trunk> | |
| 23 | + | ||
| 24 | + | ## ZIP | |
| 25 | + | ||
| 26 | + | You can download the latest version as a ZIP file from sourceforge.net: | |
| 27 | + | ||
| 28 | + | - [<http://sourceforge.net/projects/zeoslib/>](http://sourceforge.net/projects/zeoslib/) | |
| 29 | + | ||
| 30 | + | # Installing the components | |
| 31 | + | ||
| 32 | + | This is a tricky part so you should have a little patience and read this part carefully. | |
| 33 | + | ||
| 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 | + | - Start one instance of Lazarus. | |
| 36 | + | ||
| 37 | + | 1. Use **Components/Open Package File(.lpk)** from the main menu. | |
| 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 | + | 3. Press **\[Compile\]** only if you don't want to install the components into the IDE | |
| 40 | + | 4. Press **\[Install\]** | |
| 41 | + | 5. You are asked if you want to recompile Lazarus. | |
| 42 | + | ||
| 43 | + | - Answer **\[Yes\]** this time. | |
| 44 | + | - Wait until compilation ends, Lazarus should restart itself after that. | |
| 45 | + | - If all is ok you should now be able to see the **\[Zeos Access\]** tab in the Component Palette. | |
| 46 | + | ||
| 47 | + |  | |
| 48 | + | ||
| 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 | + | ||
| 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 | + | ||
| 53 | + | ``` pascal | |
| 54 | + | { This file was automatically created by Lazarus. Do not edit! | |
| 55 | + | This source is only used to compile and install the package. | |
| 56 | + | } | |
| 57 | + | unit Zcore; | |
| 58 | + | interface | |
| 59 | + | uses | |
| 60 | + | Zclasses, Zcollections, Zcompatibility, Zexprparser, Zexprtoken, Zexpression, | |
| 61 | + | Zfunctions, Zmatchpattern, Zmessages, Zsysutils, Ztokenizer, Zvariables, | |
| 62 | + | Zvariant; | |
| 63 | + | implementation | |
| 64 | + | end. | |
| 65 | + | ``` | |
| 66 | + | ||
| 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 | + | ||
| 69 | + | ` rename -v 'y/A-Z/a-z/' *` | |
| 70 | + | ||
| 71 | + | - Then, in Lazarus, reopen the package (.lpk) and fix the filename cases by clicking on "More..."/"Fix Files Case" | |
| 72 | + | - The package should compile now. | |
| 73 | + | ||
| 74 | + | # Installing Zeos components in MSEide | |
| 75 | + | ||
| 76 | + | In order to install the Zeos components: | |
| 77 | + | ||
| 78 | + | - add the path to the Zeos source to 'Project'-'Options'-'Make'-'Directories' | |
| 79 | + | - and compile the IDE with **-dmse_with_zeoslib -dMSEgui**. | |
| 80 | + | - There is a predefined IDE project **apps/ide/mseide_zeos.prj**, update 'Project'- 'Options'-'Macros' according to your installation. | |
| 81 | + | - A simple demo is in [mseuniverse](https://github.com/mse-org/mseuniverse/tree/main/samples/db/zeos). | |
| 82 | + | ||
| 83 | + | # Make your first Zeos application | |
| 84 | + | ||
| 85 | + | - Drop a **ZConnection**. | |
| 86 | + | - Set your User, Password, Host, Port and Protocol (and any other params if needed). | |
| 87 | + | - Set Connected to True. | |
| 88 | + | ||
| 89 | + | - Drop a **ZQuery** (do not mistake with ZReadOnlyQuery). | |
| 90 | + | - Set the Connection to your active ZConnection. | |
| 91 | + | - Set the Sql property to something like **SELECT * FROM MyTable** | |
| 92 | + | - Set Active to True. | |
| 93 | + | ||
| 94 | + | - Drop a **DataSource** from the **\[Data Access\]** tab. | |
| 95 | + | - Set the DataSet to your active ZQuery. | |
| 96 | + | ||
| 97 | + | - Drop a **DBGrid** from the **\[Data Controls\]** tab. | |
| 98 | + | - Set the Datasource to your DataSource. | |
| 99 | + | - If all is ok you should now be able to see the records from your table. | |
| 100 | + | ||
| 101 | + | # Possible Bugs and Issues | |
| 102 | + | ||
| 103 | + | - I have noticed that sometimes when building Lazarus it cannot find some Zeos files, as a quick workaround try this: | |
| 104 | + | - Use **Components/Package Graph** from the main menu. | |
| 105 | + | - Open the **ZComponent** package. | |
| 106 | + | - Right Click on the **Files** item in the list. | |
| 107 | + | - Choose **\[Recompile all required\]**. | |
| 108 | + | - When asked "Re-Compile this and all required packages?" answer **\[Yes\]**. | |
| 109 | + | - Recompile Lazarus normally (with packages).\ | |
| 110 | + | \ | |
| 111 | + | ||
| 112 | + | # See also | |
| 113 | + | ||
| 114 | + | - [Forum for ZeosLib](http://zeoslib.sourceforge.net/index.php) | |
| 115 | + | - [[ZeosDBO]] | |
| 116 | + | - [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 | + | ||
| 118 | + | --- | |
| 119 | + | *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).* |
