Click here to Skip to main content
Click here to Skip to main content

MySQL C++ Wrapper

By , 4 May 2003
 

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

About the Author

Kensho
Software Developer (Senior)
Portugal Portugal
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Rant[My vote of 1] I don't think so.memberJohnWallis426-Jan-10 20:06 
GeneralHimembercaesten28-May-09 9:02 
GeneralI am having "ISO C++ forbids declaration of `operator=' with no type "memberMustafanabulsi12-Sep-08 22:07 
GeneralRe: I am having "ISO C++ forbids declaration of `operator=' with no type " [modified]memberAbsalomx19-Apr-09 9:34 
Generalhelp with an clear example,, pleasememberjones16-Mar-08 19:17 
QuestionHow to find "mysql.h"memberdivide_and_conquer14-Sep-07 4:38 
AnswerRe: How to find "mysql.h"memberMaikel8320-Sep-07 23:34 
QuestionCan not locate mysql.h in win32 distributionmembersansweb19-Jul-07 4:43 
AnswerRe: Can not locate mysql.h in win32 distributionmemberEjdesgaard9-Aug-07 2:12 
GeneralMySQL with TEXT type columnmemberAlexEvans6-Jul-07 12:56 
Generalmysql connection problemmembermongol khvv4-Jul-07 23:56 
QuestionBug?memberschwarzi8118-Apr-07 23:29 
Questionhey hey hey What about *nix???memberMaxJoa30-Jan-07 17:25 
QuestionHow to get row value?member"kavin"21-Sep-06 0:48 
AnswerRe: How to get row value?membercrsreid26-Oct-07 23:00 
AnswerRe: How to get row value?membercrsreid27-Oct-07 0:38 
GeneralDon't work with MYSQL 5.0memberCHEICKNA TRAORE20-Jul-06 4:01 
GeneralRe: Don't work with MYSQL 5.0memberr4d4r29-Aug-06 4:53 
GeneralWow!memberRolando E. Cruz-Marshall11-Jul-06 8:20 
GeneralSome fixesmemberFreelanc3r28-Jun-06 0:19 
GeneralLinker ErrormemberA.T27-Jun-06 5:25 
GeneralRe: Linker Errormemberruying19-May-08 17:02 
GeneralBorland C++ Builder 6.0memberwinsth10-May-06 0:13 
GeneralI Donnow ....memberSPrutnik1-Apr-06 22:08 
Generalnewbie - error C2065: 'mysql_connect' :memberdoctorrie19-Mar-06 12:55 
GeneralRe: newbie - error C2065: 'mysql_connect' :memberfsdfdfg29-Sep-06 2:40 
GeneralRe: newbie - error C2065: 'mysql_connect' :memberruying19-May-08 17:03 
GeneralRe: newbie - error C2065: 'mysql_connect' :memberhouge15-May-10 16:44 
GeneralAdding binary datamemberprofessore16-Mar-06 12:12 
General"oops... didn't execute!!"memberkeithlee13-Mar-06 10:29 
General'sql_var_c::operator=' : must return a valuememberkuharido30-May-05 13:38 
GeneralRe: 'sql_var_c::operator=' : must return a valuememberkuharido30-May-05 13:59 
GeneralRe: 'sql_var_c::operator=' : must return a valuememberpenghong2-Sep-05 1:07 
Generalcompiling on newer MySQL 4.1.xmembermr_mark_hewitt11-Apr-05 20:53 
Generalwhoops now problem with insert...member_kane_11-Apr-05 1:30 
Generaldoesn't work for remote hostmember_kane_8-Apr-05 20:45 
GeneralRe: doesn't work for remote hostmember_kane_9-Apr-05 4:05 
Generalcompile errorssusswjmurdick13-Mar-05 13:31 
QuestionHow to detect NULL values in query results?memberAnonymous6-Jan-05 8:57 
QuestionHow do you get the name of all the database that are availablesussbenji0s10-Nov-04 9:46 
AnswerRe: How do you get the name of all the database that are availablemembermr_mark_hewitt22-Feb-06 20:29 
Generalcompile errormemberChooikw21-May-04 3:31 
GeneralRe: compile errormemberkeentyjf11-Dec-04 18:15 
Generaledate problemmemberbdiamond22-Mar-04 7:39 
GeneralPrior error solved--New onememberpatjc24-Jan-04 10:50 
Generalerror messagememberpatjc19-Jan-04 13:15 
AnswerRe: error messagememberA.T27-Jun-06 5:43 
GeneralI voted high because....memberserup5-Dec-03 3:58 
GeneralI voted high because....memberserup5-Dec-03 3:53 
GeneralCompiling Failure (error C2065: 'mysql_connect' : undeclared identifier)sussInTheZone16-Oct-03 6:38 

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

Permalink | Advertise | Privacy | Mobile
Web03 | 2.6.130704.1 | Last Updated 5 May 2003
Article Copyright 2003 by Kensho
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid