Click here to Skip to main content
15,867,453 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 258K   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

 
Rant[My vote of 1] I don't think so. Pin
JohnWallis426-Jan-10 20:06
JohnWallis426-Jan-10 20:06 
GeneralHi Pin
caesten28-May-09 9:02
caesten28-May-09 9:02 
GeneralI am having "ISO C++ forbids declaration of `operator=' with no type " Pin
Mustafanabulsi12-Sep-08 22:07
Mustafanabulsi12-Sep-08 22:07 
GeneralRe: I am having "ISO C++ forbids declaration of `operator=' with no type " [modified] Pin
Absalomx19-Apr-09 9:34
Absalomx19-Apr-09 9:34 
Generalhelp with an clear example,, please Pin
jones16-Mar-08 19:17
jones16-Mar-08 19:17 
QuestionHow to find "mysql.h" Pin
divide_and_conquer14-Sep-07 4:38
divide_and_conquer14-Sep-07 4:38 
AnswerRe: How to find "mysql.h" Pin
Maikel8320-Sep-07 23:34
Maikel8320-Sep-07 23:34 
QuestionCan not locate mysql.h in win32 distribution Pin
sansweb19-Jul-07 4:43
sansweb19-Jul-07 4:43 
AnswerRe: Can not locate mysql.h in win32 distribution Pin
Ejdesgaard9-Aug-07 2:12
Ejdesgaard9-Aug-07 2:12 
GeneralMySQL with TEXT type column Pin
AlexEvans6-Jul-07 12:56
AlexEvans6-Jul-07 12:56 
Generalmysql connection problem Pin
mongol khvv4-Jul-07 23:56
mongol khvv4-Jul-07 23:56 
QuestionBug? Pin
schwarzi8118-Apr-07 23:29
schwarzi8118-Apr-07 23:29 
Questionhey hey hey What about *nix??? Pin
MaxJoa30-Jan-07 17:25
MaxJoa30-Jan-07 17:25 
QuestionHow to get row value? Pin
"kavin"21-Sep-06 0:48
"kavin"21-Sep-06 0:48 
Can anyone tell me how to get the row value from a table by using function in mysqlplus.h?
AnswerRe: How to get row value? Pin
crsreid26-Oct-07 23:00
crsreid26-Oct-07 23:00 
AnswerRe: How to get row value? Pin
crsreid27-Oct-07 0:38
crsreid27-Oct-07 0:38 
GeneralDon't work with MYSQL 5.0 Pin
CHEICKNA TRAORE20-Jul-06 4:01
CHEICKNA TRAORE20-Jul-06 4:01 
GeneralRe: Don't work with MYSQL 5.0 Pin
r4d4r29-Aug-06 4:53
r4d4r29-Aug-06 4:53 
GeneralWow! Pin
Rolando Cruz11-Jul-06 8:20
Rolando Cruz11-Jul-06 8:20 
GeneralSome fixes Pin
Freelanc3r28-Jun-06 0:19
Freelanc3r28-Jun-06 0:19 
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 

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.