Click here to Skip to main content
15,885,546 members
Articles / Database Development / MySQL
Article

MySQL C++ Wrapper

Rate me:
Please Sign up or sign in to vote.
2.31/5 (58 votes)
4 May 2003 259.4K   4.1K   50   61
A set of C++ classes for working with the MySQL library.

Introduction

This is a simple C++ wrapper for working with MySQL... It requires the download of MySQL headers and lib (included with MySQL server here).

Sample

A simple example on how to use:

#include "mysqlplus.h"
#include <STDIO.H>
void main()
{
   sql_connection_c connection( "database", 
           "localhost", "root", "mypassword" );
   sql_query_c query( &connection );
   sql_result_c *sql_result = 0;
   if ( !query.execute( "select * from customers" ) )
   {
      printf( "oops... didn't execute!!\n" );
      return;
   }
   sql_result = query.store();
   int n_fields = sql_result->n_fields();
   for ( int idx = 0; idx < n_fields; idx++ )
   {
      sql_field_c sql_field = sql_result->fetch_field( idx );
      printf( "field %d [%s]\n", idx, sql_field.get_name() );
   }
}

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior)
Portugal Portugal
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralLinker Error Pin
A.T27-Jun-06 5:25
A.T27-Jun-06 5:25 
GeneralRe: Linker Error Pin
ruying19-May-08 17:02
ruying19-May-08 17:02 
GeneralBorland C++ Builder 6.0 Pin
winsth10-May-06 0:13
winsth10-May-06 0:13 
GeneralI Donnow .... Pin
SPrutnik1-Apr-06 22:08
SPrutnik1-Apr-06 22:08 
Generalnewbie - error C2065: 'mysql_connect' : Pin
doctorrie19-Mar-06 12:55
doctorrie19-Mar-06 12:55 
GeneralRe: newbie - error C2065: 'mysql_connect' : Pin
fsdfdfg29-Sep-06 2:40
fsdfdfg29-Sep-06 2:40 
GeneralRe: newbie - error C2065: 'mysql_connect' : Pin
ruying19-May-08 17:03
ruying19-May-08 17:03 
GeneralRe: newbie - error C2065: 'mysql_connect' : Pin
houge15-May-10 16:44
houge15-May-10 16:44 
Just replace 'mysql_connect' with 'mysql_real_connect()' with proper parameters. Smile | :)
GeneralAdding binary data Pin
professore16-Mar-06 12:12
professore16-Mar-06 12:12 
General"oops... didn't execute!!" Pin
viperlogic13-Mar-06 10:29
viperlogic13-Mar-06 10:29 
General'sql_var_c::operator=' : must return a value Pin
kuharido30-May-05 13:38
kuharido30-May-05 13:38 
GeneralRe: 'sql_var_c::operator=' : must return a value Pin
kuharido30-May-05 13:59
kuharido30-May-05 13:59 
GeneralRe: 'sql_var_c::operator=' : must return a value Pin
penghong2-Sep-05 1:07
penghong2-Sep-05 1:07 
Generalcompiling on newer MySQL 4.1.x Pin
mr_mark_hewitt11-Apr-05 20:53
mr_mark_hewitt11-Apr-05 20:53 
Generalwhoops now problem with insert... Pin
_kane_11-Apr-05 1:30
_kane_11-Apr-05 1:30 
Generaldoesn't work for remote host Pin
_kane_8-Apr-05 20:45
_kane_8-Apr-05 20:45 
GeneralRe: doesn't work for remote host Pin
_kane_9-Apr-05 4:05
_kane_9-Apr-05 4:05 
Generalcompile errors Pin
WJasonM13-Mar-05 13:31
WJasonM13-Mar-05 13:31 
QuestionHow to detect NULL values in query results? Pin
Member 5928316-Jan-05 8:57
Member 5928316-Jan-05 8:57 
QuestionHow do you get the name of all the database that are available Pin
benji0s10-Nov-04 9:46
sussbenji0s10-Nov-04 9:46 
AnswerRe: How do you get the name of all the database that are available Pin
mr_mark_hewitt22-Feb-06 20:29
mr_mark_hewitt22-Feb-06 20:29 
Generalcompile error Pin
Chooikw21-May-04 3:31
Chooikw21-May-04 3:31 
GeneralRe: compile error Pin
keentyjf11-Dec-04 18:15
keentyjf11-Dec-04 18:15 
Generaledate problem Pin
BlackDice22-Mar-04 7:39
BlackDice22-Mar-04 7:39 
GeneralPrior error solved--New one Pin
patjc24-Jan-04 10:50
patjc24-Jan-04 10:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.