Businesses that are strapped for money but need an RDBMS know that MySQL fits the bill. It works well with many programming languages, but what do you do if you need to write a multi-user database application for it in a language that it doesn't support quite as well? That's the challenge our author faced as a Delphi programmer. To see how he tackled it, keep reading.
A downloadable file for this article is available here.
After years of writing single user database applications, mainly involving MS Access, I got involved in writing a database application that required multi-user access. My client had access to a Microsoft SQL server so I wrote an application using it. This particular client was fortunate that he had money to throw at a expensive RDBMS system. Not all of my clients are that fortunate and always expect me to find the cheapest alternative.
After a very short search on the Internet I found that MySQL fitted the bill perfectly. MySQL (TM) is a very fast, multi-threaded, multi-user, and robust SQL (Structured Query Language) database server. MySQL is intended for mission-critical, heavy load production systems as well as for embedding into mass-deployed software. And best of all, it is free! It works very well with programming languages such as PHP, Perl and others.
Since I use Delphi to write most of my database applications, I wanted to find out if MySQL can be used with Delphi. Once again, I did a bit of searching on the Internet and in database-related books, and found that there is not a lot of help out there that is specific to Delphi and MySQL. Although Delphi has many database components at its disposal, none of them are really designed to work reliably with MySQL. Since most of the database components are designed to work with other Microsoft technologies only, they cannot directly be used to connect to a MySQL server.
There was our problem. We needed something that would bridge the gap between the server and the application. Luckily for us, the folks at MySQL designed what is called a database connector that handles the communication between the server and an application. So what we are going to do is use ADO components that are available in Delphi to access the information provided by the connector: