Zeos tutorial/pt

From Lazarus wiki
Jump to navigationJump to search


This tutorial is about getting, installing and using Zeoslib with Lazarus and FPC.

Getting Zeos

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:anonymous@cvs.sourceforge.net:/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:anonymous@cvs.sourceforge.net:/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.
  1. Use Components/Open Package File(.lpk) from the main menu.
  2. Go to zeosdbo_rework\packages\lazarus\ and open ZCore.lpk
  3. Press [Compile] (and wait ...)
  4. Press [Install]
  5. A message will appear informing you that this is a runtime package wich cannot be installed.
  6. Press [Ignore]
  7. You are asked if you want to recompile Lazarus.
  8. Answer [No]
  9. 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 :)