Når jeg kompilerer et mysql-eksempel i c++ skriver den følgende fejlmeddelelser:
--------------------Configuration: main - Win32 Debug--------------------
Compiling...
main.cpp
c:\\mysqlvcapi\\mysql\\include\\mysql_com.h(115) : error C2146: syntax error : missing ';' before identifier 'fd'
c:\\mysqlvcapi\\mysql\\include\\mysql_com.h(115) : error C2501: 'SOCKET' : missing storage-class or type specifiers
c:\\mysqlvcapi\\mysql\\include\\mysql_com.h(115) : error C2501: 'fd' : missing storage-class or type specifiers
d:\\my documents\\cpp\\mysql\\main.cpp(26) : warning C4244: 'initializing' : conversion from 'unsigned __int64' to 'unsigned int', possible loss of data
Error executing cl.exe.
main.obj - 3 error(s), 1 warning(s)
Jeg ved ikke om jeg har installeret mysql++ API'et for visual c++ ordentligt... jeg håber der er nogen der kan hjælpe mig
her er min kode:
#include <stdio.h>
#include <mysql.h>
#define host "localhost"
#define username ""
#define password ""
#define database "test"
MYSQL *conn;
int main()
{
conn = mysql_init(NULL);
mysql_real_connect(conn,host,username,password,database,0,NULL,0);
MYSQL_RES *res_set;
MYSQL_ROW row;
unsigned int i;
mysql_query(conn,"SELECT * FROM people");
res_set = mysql_store_result(conn);
unsigned int numrows = mysql_num_rows(res_set);
while ((row = mysql_fetch_row(res_set)) != NULL) {
for (i=0; i<mysql_num_fields(res_set); i++) {
printf("%s\\n", row[i] != NULL ? row[i] : "NULL");
}
}
mysql_close(conn);
return 0;
}