Click here to Skip to main content
12,405,700 members (70,883 online)
Click here to Skip to main content
Add your own
alternative version

Stats

208.8K views
3.5K downloads
50 bookmarked
Posted

MySQL C++ Wrapper

, 4 May 2003
Rate this:
Please Sign up or sign in to vote.
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

Share

About the Author

Goncalo Oliveira
Software Developer (Senior)
Portugal Portugal
No Biography provided

You may also be interested in...

Comments and Discussions

 
Rant[My vote of 1] I don't think so. Pin
JohnWallis426-Jan-10 20:06
memberJohnWallis426-Jan-10 20:06 
GeneralHi Pin
caesten28-May-09 9:02
membercaesten28-May-09 9:02 
GeneralI am having "ISO C++ forbids declaration of `operator=' with no type " Pin
Mustafanabulsi12-Sep-08 22:07
memberMustafanabulsi12-Sep-08 22:07 
GeneralRe: I am having "ISO C++ forbids declaration of `operator=' with no type " [modified] Pin
Absalomx19-Apr-09 9:34
memberAbsalomx19-Apr-09 9:34 
Generalhelp with an clear example,, please Pin
jones16-Mar-08 19:17
memberjones16-Mar-08 19:17 
QuestionHow to find "mysql.h" Pin
divide_and_conquer14-Sep-07 4:38
memberdivide_and_conquer14-Sep-07 4:38 
AnswerRe: How to find "mysql.h" Pin
Maikel8320-Sep-07 23:34
memberMaikel8320-Sep-07 23:34 
QuestionCan not locate mysql.h in win32 distribution Pin
sansweb19-Jul-07 4:43
membersansweb19-Jul-07 4:43 
AnswerRe: Can not locate mysql.h in win32 distribution Pin
Ejdesgaard9-Aug-07 2:12
memberEjdesgaard9-Aug-07 2:12 
GeneralMySQL with TEXT type column Pin
AlexEvans6-Jul-07 12:56
memberAlexEvans6-Jul-07 12:56 
Generalmysql connection problem Pin
mongol khvv4-Jul-07 23:56
membermongol khvv4-Jul-07 23:56 
QuestionBug? Pin
schwarzi8118-Apr-07 23:29
memberschwarzi8118-Apr-07 23:29 
Questionhey hey hey What about *nix??? Pin
MaxJoa30-Jan-07 17:25
memberMaxJoa30-Jan-07 17:25 
QuestionHow to get row value? Pin
"kavin"21-Sep-06 0:48
member"kavin"21-Sep-06 0:48 
AnswerRe: How to get row value? Pin
crsreid26-Oct-07 23:00
membercrsreid26-Oct-07 23:00 
AnswerRe: How to get row value? Pin
crsreid27-Oct-07 0:38
membercrsreid27-Oct-07 0:38 
GeneralDon't work with MYSQL 5.0 Pin
CHEICKNA TRAORE20-Jul-06 4:01
memberCHEICKNA TRAORE20-Jul-06 4:01 
GeneralRe: Don't work with MYSQL 5.0 Pin
r4d4r29-Aug-06 4:53
memberr4d4r29-Aug-06 4:53 
GeneralWow! Pin
Rolando E. Cruz-Marshall11-Jul-06 8:20
memberRolando E. Cruz-Marshall11-Jul-06 8:20 
GeneralSome fixes Pin
Freelanc3r28-Jun-06 0:19
memberFreelanc3r28-Jun-06 0:19 
GeneralLinker Error Pin
A.T27-Jun-06 5:25
memberA.T27-Jun-06 5:25 
GeneralRe: Linker Error Pin
ruying19-May-08 17:02
memberruying19-May-08 17:02 
GeneralBorland C++ Builder 6.0 Pin
winsth10-May-06 0:13
memberwinsth10-May-06 0:13 
GeneralI Donnow .... Pin
SPrutnik1-Apr-06 22:08
memberSPrutnik1-Apr-06 22:08 
Generalnewbie - error C2065: 'mysql_connect' : Pin
doctorrie19-Mar-06 12:55
memberdoctorrie19-Mar-06 12:55 
GeneralRe: newbie - error C2065: 'mysql_connect' : Pin
fsdfdfg29-Sep-06 2:40
memberfsdfdfg29-Sep-06 2:40 
GeneralRe: newbie - error C2065: 'mysql_connect' : Pin
ruying19-May-08 17:03
memberruying19-May-08 17:03 
GeneralRe: newbie - error C2065: 'mysql_connect' : Pin
houge15-May-10 16:44
memberhouge15-May-10 16:44 
GeneralAdding binary data Pin
professore16-Mar-06 12:12
memberprofessore16-Mar-06 12:12 
General"oops... didn't execute!!" Pin
keithlee13-Mar-06 10:29
memberkeithlee13-Mar-06 10:29 
General'sql_var_c::operator=' : must return a value Pin
kuharido30-May-05 13:38
memberkuharido30-May-05 13:38 
GeneralRe: 'sql_var_c::operator=' : must return a value Pin
kuharido30-May-05 13:59
memberkuharido30-May-05 13:59 
GeneralRe: 'sql_var_c::operator=' : must return a value Pin
penghong2-Sep-05 1:07
memberpenghong2-Sep-05 1:07 
Generalcompiling on newer MySQL 4.1.x Pin
mr_mark_hewitt11-Apr-05 20:53
membermr_mark_hewitt11-Apr-05 20:53 
Generalwhoops now problem with insert... Pin
_kane_11-Apr-05 1:30
member_kane_11-Apr-05 1:30 
Generaldoesn't work for remote host Pin
_kane_8-Apr-05 20:45
member_kane_8-Apr-05 20:45 
GeneralRe: doesn't work for remote host Pin
_kane_9-Apr-05 4:05
member_kane_9-Apr-05 4:05 
Generalcompile errors Pin
wjmurdick13-Mar-05 13:31
susswjmurdick13-Mar-05 13:31 
QuestionHow to detect NULL values in query results? Pin
Anonymous6-Jan-05 8:57
memberAnonymous6-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
membermr_mark_hewitt22-Feb-06 20:29 
Generalcompile error Pin
Chooikw21-May-04 3:31
memberChooikw21-May-04 3:31 
GeneralRe: compile error Pin
keentyjf11-Dec-04 18:15
memberkeentyjf11-Dec-04 18:15 
Generaledate problem Pin
bdiamond22-Mar-04 7:39
memberbdiamond22-Mar-04 7:39 
GeneralPrior error solved--New one Pin
patjc24-Jan-04 10:50
memberpatjc24-Jan-04 10:50 
Generalerror message Pin
patjc19-Jan-04 13:15
memberpatjc19-Jan-04 13:15 
AnswerRe: error message Pin
A.T27-Jun-06 5:43
memberA.T27-Jun-06 5:43 
GeneralI voted high because.... Pin
serup5-Dec-03 3:58
memberserup5-Dec-03 3:58 
GeneralI voted high because.... Pin
serup5-Dec-03 3:53
memberserup5-Dec-03 3:53 
GeneralCompiling Failure (error C2065: 'mysql_connect' : undeclared identifier) Pin
InTheZone16-Oct-03 6:38
sussInTheZone16-Oct-03 6:38 

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.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160721.1 | Last Updated 5 May 2003
Article Copyright 2003 by Goncalo Oliveira
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid