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:
- Server - If you are on a network, your host name might be different; check with whoever controls the network.
- User - Usually the "root."
- Password - Usually empty, but you can create a username and password in the MyCC interface.
- 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.
Next: The Application >>
More Delphi-Kylix Articles
More By Leidago