Previous page Previous     TOC Contents     Next pageNext

Database programming sample

Here's a new sample that uses Visual Basic ADO programming to build a client for a MySQL database.

The application runs the "Project management" database that we create in the SQL tutorial. You may want to study the model. It is developed all through the tutorial, starting at Lesson 2. See SQL TutorialLesson 2.

To run the application you will need to install the MySQL virtual private server . You can get that also from the SQL tutorial at SQL Lesson 3B.

Once you've got the MySQL server installed and running, you can download the sample database. Simply extract the folder from the .zip file and make sure it's in c:/mysql/data. The folder is your MySQL database.

Use this link to get the MySQL database: Project management database download.

And finally, you will have to create the appropriate data source (DSN) to connect to the MySQL database. Call the DSN "projectmgt", to match the name used in the application.

If you haven't used MySQL before you have to be aware that the MySQL driver is not included in Windows data sources. You will have to download it from MySQL. Use this site: MySQL ODBC driver and download the Windows file. When you execute the file it will install the driver in data sources.

We have to assume that since you've gotten to this point in database programming, you know how to create a DSN. In case you don't, just go to the Control panel --> Administrative tools --> Data sources (ODBC) and proceed from there.

The VB application will eventually be used to perform maintenance tasks on all tables of the database.

To begin, we will only do two: the Employees and the Departments tables.

However, the code for the other tables would be very similar to the first two.

Notice that the SQL code embedded in the forms is the link from VB to the database server.

Download the VB application from here: Project Management ADO application.

For additional VB resources you might find this site useful:
Free Visual Basic 6 tutorials and sample source code examples .

If you haven't found the Visual Basic resource you're looking for,
use our Google Search box for more information.