MySQLWrapp: MFC-Extension Library for MySQL
Using MySQLWrapp in Your Application
- Build MySQLWrapp.dll.
- Include in your application "MySQLWrapp.h".
- In "Project settings/Lib/Object library modules" field add (full path and) file name of MySQLWrapp.lib, e.g. "c:\MyProject\lib/MySQLWrapp.lib". You can also use pragma comment in your source code, for example
#pragma comment(lib,_T("\\MyProject\\lib/MySQLWrapp.lib")) - Don't forget to include <AfxTempl.h> in StdAfx.h, because MySQLWrapp uses CArray MFC template class.
- Be sure that MySQLWrapp.dll and libmysql.dll are in the same folder with your application executable file.
Demo Application
(Full Size Image)
Brief description
The demo application is a simple UI client (DemoUIClient.exe).
Wrapper classes described in this article are implemented in SQLWrapp.dll.
MySQL C API functions are exported from libmysql.dll which is shipped with MySQL install kit. Please copy libmysql.dll into the application folder.
Left pane tree contains:
- connection info, i.e. user and host in the root;
- database names;
- table names for each database.
Right pane displays:
- if a database is selected - information about its tables (SHOW TABLE STATUS);
- if a table is selected - table contents (SELECT * FROM table);
- the result of a query entered by the user (see SQL/Query menu item).
For BLOB fields "<blob>" string is displayed in the list.
If click in a <blob> field and it contains a image (BITMAP, GIF, or JPEG) this is displayed in a picture tool window.
To update a <blob> field from a file right-click on it.
Demo Database
To install the demo database you can use mysql.exe command-line tool:- download and unzip test_db.sql script file.
- launch mysql.exe from command line.
- use source command to execute the SQL script file.
C:\Program Files\MySQL\MySQL Server 5.0\bin>mysql --user=root --password=root Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 to server version: 5.0.7-beta-nt Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> source c:\test_db.sql
Final notes
- Here you can download MySQL Database Server & standard clients. Because there are more versions available, I recommend the last stable release (non-beta).
- MySQLWrapp was tested on MySQL versions 4.0.24, 4.1.11, and 5.0.7-beta.
- libmysql.dll, libmysql.lib, and mysql header files are shipped with MySQL Database Server & standard clients.
- The demo application is only for testing purpose and designed to be very simple. It has its limitations, and its not a full featured MySQL UI client application.
About the Author
Graduated at "Gh. Asachi" Technical University - Iasi, Romania.
Programming in C++ using Microsoft technologies since 1995.
Microsoft MVP awardee since 2006.
Moderator and article reviewer at Codeguru.com, the number one developer site.
Co-founder of Codexpert.ro, a website dedicated to Romanian C++ developers.
Downloads
IT Offers
More for Developers
Top Authors
- Voted: 13 times.
- Voted: 11 times.
- Voted: 11 times.
- Voted: 8 times.
- Voted: 8 times.
- Paul Kimmel 214 articles
- Zafir Anjum 120 articles
- 15Seconds.com 99 articles
- Tom Archer - MSFT 83 articles
- Jeffrey Juday 82 articles


All