Difference between revisions of "MySQLDatabases"

From Lazarus wiki
Jump to navigationJump to search
Line 16: Line 16:
 
If you do not know how to install components / packages, have a look at this [[Install Packages|page]] for an "Install Howto".
 
If you do not know how to install components / packages, have a look at this [[Install Packages|page]] for an "Install Howto".
 
As the SQLdb components are the more general and can be used for other databases just by replacing the TMySQLConnection with for instance a TIBConnection, we will develop a program with the SQLdb components.
 
As the SQLdb components are the more general and can be used for other databases just by replacing the TMySQLConnection with for instance a TIBConnection, we will develop a program with the SQLdb components.
 +
 +
==Our program==

Revision as of 13:30, 7 April 2005

Introduction

Work in progress

In the Database tutorial we saw a first attempt to connect to a MySQL server. We did not use any components, either visual or non-visual at that time. This page will explain how to connect to a MySQL server in a (perhaps) easier way.

Components to use

MySQL Components

If you look in the $Lazarus/components/mysql directory you will find two lazarus packages. There is a package for MySQL version 3.2x (mysql3laz.lpk) and one for MySQL version 4.x (mysql4laz.lpk). If you did not do so yet, install the appropriate package, depending on the server version. Remember that it is not possible to use the package for version 3 to connect to a server running version 4 or vice versa. When you've installed this package you will see a new tab in the component palet, called MySQL. On this tab there are two components, TMySQLDatabase and TMySQLDataset.

SQLdb Components

Another possibility is the installation of the package in the $Lazarus/components/sqldb directory. In this directory you see a package file called sqldblaz.lpk. You need to install this package and the mysql4connlaz.lpk form the $Lazarus/components/sqldb/mysql directory. The first package contains some general components used for all databases. These component are TSQLTransation and TSQLQuery and can be found on the new SQLdb tab. After installation of the mysql4connlaz.lpk you will find a third component on the SQLdb tab called TMySQLConnection (depicted by a dolphin).

If you do not know how to install components / packages, have a look at this page for an "Install Howto". As the SQLdb components are the more general and can be used for other databases just by replacing the TMySQLConnection with for instance a TIBConnection, we will develop a program with the SQLdb components.

Our program