CodeGuru
Earthweb Search
Forums Wireless Jars Gamelan Developer.com
CodeGuru Navigation
RSS Feeds

RSSAll

RSSVC++/C++

RSS.NET/C#

RSSVB

See more EarthWeb Network feeds

follow us on Twitter

Member Sign In
User ID:
Password:
Remember Me:
Forgot Password?
Not a member?
Click here for more information and to register.

Become a Marketplace Partner

jobs.internet.com

internet.commerce
Partners & Affiliates
















Home >> Visual C++ / C++ >> Data >> Database >> Misc.


MySQLWrapp: MFC-Extension Library for MySQL
Rating:

Ovidiu Cucu (view profile)
June 28, 2005

Environment:  Windows 9x/NT, Visual C++, MySQL

Go to page: Prev  1  2  


(continued)



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.
Example
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 with a degree in Electronics and Telecommunications from the Technical University of Iasi in 1986. However, in 1994 he again met his first love from high school: computer science. He began programming at a company specializing in financial software. Since 2002, he's been a project manager for WAM (work area management) applications used in medical laboratories. During that time, he's dealt with many programming languages, beginning with old Fortran. Actually, he programs in C++ using Visual Studio, MFC, Windows API, and COM.

Go to page: Prev  1  2  

Downloads

  • MySQLDemo.zip - MySQLWrapp and demo application sources
  • test_db.zip - Demo database

    Tools:
    Add www.codeguru.com to your favorites
    Add www.codeguru.com to your browser search box
    IE 7 | Firefox 2.0 | Firefox 1.5.x
    Receive news via our XML/RSS feed







  • RATE THIS ARTICLE:   Excellent  Very Good  Average  Below Average  Poor  

    (You must be signed in to rank an article. Not a member? Click here to register)

    Latest Comments:
    Build Error - param_joshi (09/24/2008)
    app keeps crashing/freezing - xRomano (04/13/2007)
    Number of rows in CSQLResult - Bui Tan Duoc (12/15/2006)
    Reading Text Format Problem - dacky (10/25/2006)
    Errors and Questions - dacky (10/25/2006)

    View All Comments
    Add a Comment:
    Title:
    Comment:
    Pre-Formatted: Check this if you want the text to display with the formatting as typed (good for source code)



    (You must be signed in to comment on an article. Not a member? Click here to register)

    internet.comearthweb.comDevx.commediabistro.comGraphics.com

    Search:

    Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

    Jupitermedia Corporate Info

    Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
    Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers