Coba sebagai berikut:
MYSQL mysql,*connection;
MYSQL_RES result;
MYSQL_ROW row;
mysql_init(&mysql);
connection =mysql_real_connect(&mysql,"localhost","root","12356","hari",0,NULL,0);
if (connection==NULL)
{
cout<<mysql_error(&mysql)<<endl;
}
else{
nQueryState = mysql_query(&mysql,"insert into userdetails values('"+nId+"','"+szName+"','"+szPassword+"','"+szQuestion+"','"+szPhone+"')");
if (nQueryState !=0) {
cout << mysql_error(connection) << endl;
return 1;
}
}
mysql_close(&mysql);
Lihat:http://www .codeproject.com/Questions/337901/How-to-insert-data-in-database-using-Cplusplus