Finally, you saw how everything comes together—how using VBScript in an ASP can manipulate a
database using ADO.
Q&A
Q: Can I add a user with this technology?
A:
With ADO, you can accomplish anything you can do at the MySQL monitor
command line. You can add users, flush privileges, and even optimize your
tables programmatically.
Q:
It seems like you are adding a lot of interface layers. How does this
affect performance?
A:
Even with the added layers, ADO is extremely fast. This lesson has used a
MySQL database and a Visual Basic application over a dial-up connection.
The users didn’t even know they were accessing their database remotely.
That’s how fast it is.
Q: Can I only use ADO in Active Server Pages?
A:
No. ASPs are only one place where you can use ADO. Visual Basic, Java,
and Visual C++ can all use ADO. The only requirement is that you have the
myodbc driver installed. You cannot access any MySQL databases without
it.
Q: Why should I even bother with a DSN?
A:
A DSN provides you with a quick and easy way to access your database. It
is great for the desktop. Also, other applications need a DSN to access
ODBC data sources. For example, to import or export anything out of
Microsoft Access you need a DSN. Additionally, you can change the
database without having to rebuild your application.
Exercises
- Using ADO, connect to the MySQL database and optimize your tables.
- Create an ASP that allows a user to edit data from the Customers table.
Day 14: The Perl Database Interface
Overview
The Perl language was developed in 1987 by Larry Wall. Since then, Perl has become one of the most
popular programming languages used in the computer industry. It runs on nearly every computer platform
(including Windows) and can be ported very easily, sometimes without changing a line of code. It is a very
robust language with very strong string manipulation capabilities. This makes Perl an excellent choice for
CGI programs, as well as many other business applications.
Because of Perl's popularity, it was only a matter of time before people started using Perl to interact with
databases. The very first versions of these modules were a little cumbersome compared to what is
available today. Back then, each database had its own module that was specific to that database.
These modules were named after their database-producing names, such as Sybperl and Oriperl. These
were good at the time, but did not fit the heterogeneous data model that was becoming a standard in
the industry. Enter the Perl Database Interface, commonly referred to as DBI. DBI provided
programmers with a standard set of functions and variables to use to access any database—much like
ODBC provides access to databases on the Windows platform. The interface talked to a driver that was
specific to the database. This part of the architecture is called the DBD or database driver. These two
parts combined provide an architecture that is easy to learn and use. Fortunately, MySQL has a DBD.
This allows you to use Perl to interface your MySQL database.
Today, you will learn
How to install the DBI/DBD driver for MySQL
How to use the MySQL DBI/DBD
How to create a CGI program that interacts with a MySQL database