Hello everybody,
I have another problem(Of Course). I am testing out a short little program I found on a forum that connects to a MySql database and runs a query. From what I can tell, the syntax looks fairly correct, I just keep getting some build errors. I am running on XP, using .NET, and have downloaded and setup MYSQL. The database is there and I have been able to run queries from the command line. I added the lib and include directories. Apparently it is finding some of the files. Here is the code followed by the errors:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <c:/mysql/include/mysql.h>
#define host "appsrvr"
#define username "root"
#define password "nbtis01"
#define database "mysql"
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 user, host, password FROM user");
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;
}
Here are the errors:
Code:
Compiling...
SQL Practice.cpp
c:\mysql\include\mysql_com.h(116) : error C2146: syntax error : missing ';' before identifier 'fd'
c:\mysql\include\mysql_com.h(116) : error C2501: 'st_net::SOCKET' : missing storage-class or type specifiers
c:\mysql\include\mysql_com.h(116) : error C2501: 'st_net::fd' : missing storage-class or type specifiers
c:\mysql\include\mysql_com.h(180) : error C2065: 'SOCKET' : undeclared identifier
c:\mysql\include\mysql_com.h(180) : error C2146: syntax error : missing ')' before identifier 's'
c:\mysql\include\mysql_com.h(181) : error C2059: syntax error : ')'
c:\Documents and Settings\kgoodrich.SCANNER\My Documents\Visual Studio .NET Projects\SQL Practice\SQL Practice.cpp(25) : warning C4244: 'initializing' : conversion from 'my_ulonglong' to 'unsigned int', possible loss of data
Any ideas why those errors would pop up. I would not think that the syntax would be wrong, because I installed everything from the binary download off of mysql.com. Any ideas would be greatly appreciated.
Thanks a mil,
Kendal