Difference between revisions of "TPSQL"

From Lazarus wiki
Jump to navigationJump to search
Line 31: Line 31:
  
 
Issues:  
 
Issues:  
Tested on Windows (Win2K) and Linux (Mdk 10.1). Database server: PostgreSQL 8.0.3 (on both platforms).
+
Tested on Windows (Win2K) and Linux (Mdk 10.1). Database server: PostgreSQL 8.0.3 (running on both platforms).
  
 
===Installation===
 
===Installation===

Revision as of 11:44, 3 June 2005

About

TPSQL is a modified-LGPL package for Lazarus. It defines two components, TPSQLDatabase and TPSQLDataset, allowing applications to connect to PostgreSQL database servers over TCP/IP networks.


The download contains the component Pascal files, the Lazarus package file and resource files and the modified-LGPL license text files.

This component was designed for applications running on Linux and Win32 platforms.

Author

Antonio d'Avino

License

Modified LGPL (read COPYING.modifiedLGPL and COPYING.LGPL included in package).

Download

The latest stable release can be found on the http://infoconsult.homelinux.net.

Change Log

  • Version 0.4.0 2005/06/01
  • Version 0.4.2 2005/06/03
 ClientEncoding property added to TPSQLDatabase class. 
 Some changes to destroy method of TPSQLDatabase/TPSQLDataset 
 for avoiding exception when closing IDE/project with components 
 in Active/Connected status.

Dependencies / System Requirements

  • Lazarus 0.9.6 (FPC 1.9.8)

Status: Beta

Issues: Tested on Windows (Win2K) and Linux (Mdk 10.1). Database server: PostgreSQL 8.0.3 (running on both platforms).

Installation

  • In the lazarus/components directory, untar (unzip) the files from psql_laz.tar.gz file. The psql folder will be created.
  • Open lazarus
  • Open the package psql_laz.lpk with Component/Open package file (.lpk)
  • Click on Compile
  • Click on Install and answer 'Yes' when you are asked about Lazarus rebuilding. A new tab named 'PSQL' will be created in the components palette.

Note for Win32 users: In case you experience some difficults in compiling the Pascal files, you may need to add the following path: <some-drive>:<some-path>\lazarus\lcl\units\i386\win32 (ie: c:\programs\lazarus\lcl\units\i386\win32) to the 'Other units path ...' in 'Paths' tab of 'Compiler Options' of the lazarus package manager window.

Usage

Drop a TPSQLDatabase component on a form, for any different PostgreSQL database your application needs to connect to. Mandatory property of this component you have to set are:

  • DatabaseName : The name of the PostgreSQL database that your application needs to connect to.
  • HostName : the IP address or the URL of the PC hosting the PostgreSQL server.
  • UserName : a user name have permission to access host/database.

Optionally you may need to set Password property for correct connection to server. Then, to activate the connection, you neet to set the Connected property to 'True'. An exception will be raised if connection failed (wrong parameters, user with no permission to access the host/database, network errors or PostgreSQL server not active). Set this property to 'False' for closing connection.

Now you may drop a TPSQLDataset component on the form for any table connection you need. The main property to set on this component type is the Database one. A dropdown menu allows you to select one of any TDatabase descendant component present on form (of course, you must select a TPSQLDatabase component).

You also need to provide a valid SQL statement in SQL property. Now, you are able to open the TPSQLDataset, setting to 'True' the Active property. Several exceptions are provided for signaling failing conditions. Please, refer to TDataSet documentation for infos and examples about using the TPSQLDataset component in order to access to SQL retrieved data rows as well as conneting to Data Controls components.