Hallo Leute.
Ich versuche in C++ auf eine MYSQL Datenbank zu connecten.
Dafür brauche ich allerdings die C API für MYSQL.
Woher krieg ich die?
Ich finde im google nichts.
Brauche halt üblich include files wie mysql.h , mysql_time.h usw.
Zudem Code habe ich noch eine Frage.
Ich möchte gerne das der Benutzername und das Password abgefragt wird und nicht fest im CPP code intrigiert ist.
Wie mache ich das am besten ?
#include <winsock.h>
#include <mysql.h>
#include <stdio.h>
int main()
{
MYSQL *conn;
MYSQL_RES *res;
MYSQL_ROW row;
conn = mysql_init ( NULL );
mysql_real_connect (
conn, /* pointer to connection handler */
"localhost", /* host to connect to */
"username", /* user name */
"password", /* password */
"database", /* database to use */
0, /* port (default 3306) */
NULL, /* socket or /var/lib/mysql.sock */
0 ); /* flags (none) */
mysql_query(conn,"show tables");
res = mysql_store_result(conn);
while ( row = mysql_fetch_row(res) )
{
printf ("%s\n", row[0]);
}
printf ("\n%lu rows affected\n",
(unsigned long) mysql_num_rows(res));
mysql_close(conn);
return 0;
}[/PHP]