connect C++ with mysql

J try to connect my database with c++, but when J compile in тhe output write me that no database selected..
My code is:

#include <windows.h>
#include <sql.h>
#include <sqlext.h>
#include <sqltypes.h>
#include <iostream>
#include "C:\wamp\bin\mysql\mysql5.5.24\bin\mysql.h"

using namespace std;

int main()
{
MYSQL *connect;
MYSQL_RES *result;
MYSQL_ROW row;

connect = mysql_init(NULL);
if (mysql_real_connect(connect,"localhost","root","","kompjuterska_oprema",0,NULL,0) !=0)
{
cout << "Succesfully Connected to MySQL database " << endl;
}
else
{
cout << "Was not able to connect to database";
}
mysql_close(connect);


system("pause");
return 0;
}
Can you help me? Њhere is my mistake?
You gave the wrong input to the connect function. The standard format is
mysql_real_connect(handle, host, user, password, database, ...) you assigned 0 to database. My guess is, you ignored the password field, the current password being "kompjuterska_oprema". Have phun!
Try to use 'SOCI' library,
I made an update for last version of MySQL can share it if you like to.
Topic archived. No new replies allowed.