This tutorial is about getting, installing and using Zeoslib with Lazarus and FPC.
The Zeos team has recently made a new forum, Please visit the new forum for more information about ZeosLib and to ask/answer questions about using Zeos and report bugs. The new forum can be found here Forum for ZeosLib or here Zeos Forum
Zeos has recently been ported to Lazarus and there are no releases yet that officially support it but you can easily get it from CVS if you follow these steps:
- Set the system path to include your cvs client (if necessary) depending on what client you chose or configure your GUI client to use this CVSROOT -d:pserver:email@example.com:/cvsroot/zeoslib.
- If you have configured your system path open a terminal/console/dosbox and go to the directory where you store your cvs and type:
cvs -d:pserver:firstname.lastname@example.org:/cvsroot/zeoslib checkout zeoslib_rework
- You should see some progress, after all files have been downloaded go to the zeosdbo_rework directory and have a look at what it contains.
Installing the components
This is a tricky part so you should have a little patience and read this part carefully.
- Start one instance of Lazarus.
- Use Components/Open Package File(.lpk) from the main menu.
- Go to zeosdbo_rework\packages\lazarus\ and open ZCore.lpk
- Press [Compile] (and wait ...)
- Press [Install]
- A message will appear informing you that this is a runtime package wich cannot be installed.
- Press [Ignore]
- You are asked if you want to recompile Lazarus.
- Answer [No]
- Close the instalation form.
- Repeat steps 1 to 9 for the folowing packages (Open them instead of Zcore.lpk):
- - ZParseSql.lpk
- - ZPlain.lpk
- - ZDbc.lpk
- Now repeat steps 1 to 6 for the package ZComponent.lpk
- You are asked to recompile Lazarus.
- Answer [Yes] this time.
- Wait until compilation ends, Lazarus should restart itself after that.
- If all is ok you should now be able to see the [Zeos Access] tab in the Component Palette.
Make your first Zeos application
- Drop a ZConnection.
- Set your User, Password, Host, Port and Protocol (and any other params if needed).
- Set Connected to True.
- Drop a ZQuery (do not mistake with ZReadOnlyQuery).
- Set the Connection to your active ZConnection.
- Set the Sql property to something like SELECT * FROM MyTable
- Set Active to True.
- Drop a DataSource from the [Data Access] tab.
- Set the DataSet to your active ZQuery.
- Drop a DBGrid from the [Data Controls] tab.
- Set the Datasource to your DataSource.
- If all is ok you should now be able to see the records from your table.
More information about working with Zeos
Please complete me :)
Possible Bugs and Issues
- I have noticed that somethimes when buliding Lazarus it cannot find some Zeos files, as a quick workaround try this:
- Use Components/Package Graph from the main menu.
- Open the ZComponent package.
- Right Click on the Files item in the list.
- Chose [Recompile all required].
- When asked "Re-Compile this and all required packages?" answer [Yes].
- Recompile Lazarus normally (with packages).
- There is a bug in FPC's AnsiStrComp wich causes unreliable PChar comparison, this is obvious when using a DBGrid to edit data, AnsiStrComp('abc', 'abcd') can't detect them as being different but it detects AnsiStrComp('abd', 'abcd') ignoring multiple chars from the second string. This bug was found by Jesusrmx. It will probably be fixed this week, see Bug Report.