I've never tried C++ and mySQL, but I've tried C++ and Oracle SQL.
It was somethign with a pseudo C++ code, you would run through a precompiler, and the code segment you'd use to connect would be like:
Code:
exec sql begin declare section;
/*
the username/database/fields/etc
which you would use in C++ to connect
declared. Ie:
*/
char *uid = "scott/tiger";
char name[NAMELEN];
int salary, commission;
short comm_ind;
exec sql end declare section;
exec sql whenever sqlerror goto error;
exec sql connect :uid;
exec sql declare c cursor for
select ename, sal, comm from emp where job = 'SALESMAN'
order by ename;
exec sql open c;
exec sql fetch c into :name, :salary, :commission:comm_ind;
exec sql close c;
exec sql rollback release;
exit(0);
error:
cout << endl << sqlca.sqlerrm.sqlerrmc << endl;
exec sql rollback release;
exit(1);
The precompilation would then exchange all the
exec sql [something] with the appropriate C++ calls to the SQL database.
But it would be strange, if there wasn't a way to get C++ programs and mySQL to talk with eachother.