MYSQL mysql;
MYSQL_RES* res;
MYSQL_ROW row;
MYSQL_FIELD* field;
mysql_init(&mysql);
mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, "gbk");
mysql_real_connect(&mysql, "10.100.248.103", "root", "123456", "kongtiao", 3306, NULL, 0) == NULL;
int ret = mysql_query(&mysql, "select * from gree;");
res = mysql_store_result(&mysql);
while (row = mysql_fetch_row(res))
{
printf("%s\n",row[0]);
}
mysql_free_result(res);
mysql_close(&mysql);
system("pause");
return 0;
代码如上,想查询数据库内某行某列的具体一个数,但怎么写只能查看某一列或某一行。如果加上
while (field = mysql_fetch_field(res))
{
printf("%s\n",field[0]);
}
在查询行数据代码的话,他就会乱码。求指导