Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

MySQL C++ Wrapper

0.00/5 (No votes)
4 May 2003 1  
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