Home arrow Delphi-Kylix arrow Page 3 - Using Delphi with MySQL
DELPHI-KYLIX

Using Delphi with MySQL


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.

Author Info:
By: Leidago
Rating: 5 stars5 stars5 stars5 stars5 stars / 22
October 25, 2006
TABLE OF CONTENTS:
  1. · Using Delphi with MySQL
  2. · Required Tools
  3. · Setting up the Connector
  4. · The Application
  5. · Form Two

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Using Delphi with MySQL - Setting up the Connector
(Page 3 of 5 )

So start up the MyCC application that you just installed. It should look something like this when opened:

Now right click on the Database header and select new Database:

and type in "publish." The database name should now appear on the list of databases. Click on it and then go to the tool bar and find the button that says "SQL." Click on it and a new window should appear. Add the following SQL:

CREATE TABLE `articles` (
  `aID` int(4) NOT NULL auto_increment,
  `auth` varchar(100) NOT NULL default '',
  `title` varchar(100) NOT NULL default '',
  `article_body` text NOT NULL,
  `date_published` date NOT NULL default '0000-00-00',
  PRIMARY KEY  (`aID`)
)
INSERT INTO `articles` VALUES (1, 'Leidago !Noabeb', 'Using
Delphi with MYSQL', 'It is really not that hard to do. Hey, if i
can do it....', '2006-07-09');
INSERT INTO `articles` VALUES (2, 'John Doe', 'Yes!', 'Than you
can do it!!!', '2011-07-20');
INSERT INTO `articles` VALUES (1, 'Joe Blogg', 'It is a breeze...',
'It really is not that hard to do. Just give it a go....', '2006-
07-09');
INSERT INTO `articles` VALUES (2, 'John Doe', 'Patience', 'That's
all you need to do it!!!', '2011-07-20');

You should now have a database called publish and a table called articles with a couple of sample records in it. Now we need to create a connection between the database and the ODBC connector. Close down MyCC, go to the control panel, click on "Performance and maintenance," then click on "Administration tools." You should now see the screen below:

Now, click on the link that says "Data Source/ODBC." You should now have the following screen:

Click on "add." This will start the process of creating a new database connection. You should see the following window:

This window lists all the drivers on your system. Find the ODBC connector driver and select "finish." You should see the following window:

Try to fill in the details of the screen as they are on the example above.

There are four important fields that might differ from my details:

  1. Server - If you are on a network, your host name might be different; check with whoever controls the network.
  2.  User - Usually the "root."
  3.  Password -  Usually empty, but you can create a username and password in the MyCC interface.
  4.  Database - Just select from the dropdown list.

Finally, click the "test" button and check that everything is okay. If not, the problem is most likely to be the server, password or user name, so check them all. Then click "ok" and you should see the following screen with your new connection listed:

That's it for connecting the database to the connector. Now all the work that we are going to do with our Delphi application is going to be done through the connector to the database and back. I am using an XP machine, so your control panel applets will not necessarily be the same as mine. Please be aware of this.


blog comments powered by Disqus
DELPHI-KYLIX ARTICLES

- Loading an XML Document into the DOM
- Delphi Wrapper Classes and XML
- Delphi and the DOM
- Delphi and XML
- Internet Access: Client Service
- Finishing the Client for an Internet Access ...
- The Client for an Internet Access Control Ap...
- User Management for an Internet Access Contr...
- Important Procedures for an Internet Access ...
- Server Code for an Internet Access Control A...
- Constructing the Interface for an Internet A...
- Building a Server Application for an Interne...
- Building an Internet Access Control Applicat...
- Client Dataset: Working with Data Packets an...
- Using the Client Dataset in an N-Tiered Appl...

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 2 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials