c程序查询mysql数据库的问题!!!急急急急!!!
#include <stdio.h>
#include <mysql.h>
#define host_name "localhost"
#define user_name "root"
#define password "linq2002"
#define db_name "linq"
MYSQL *cnx_init;
MYSQL *cnx_db;
MYSQL_RES *result_set;
MYSQL_ROW row;
unsigned int ctr;
char *query;
/*****************************/
void show_result_set(MYSQL_RES *in_result_set);
int main(int argc, char *argv[]){
printf("starting.....\n");
cnx_init = mysql_init(NULL);
if(cnx_init == NULL){
printf("failure in mysql_init\n");
printf("exit code 1!");
exit(1);
}
cnx_db = mysql_real_connect(cnx_init,host_name,user_name,password,db_name,0,NULL,0);
if(cnx_db == NULL){
printf("failure in mysql_real_connect\n");
printf("exit code 2!\n");
exit(2);
}
printf("database\n");
printf("------------------\n");
if(mysql_query(cnx_init,"SHOW DATABASES") != 0){
printf("failure in show database!\n");
printf("exit code 3!\n");
exit(3);
}
else {
result_set=mysql_store_result(cnx_init);
if(result_set == NULL)
printf("failure in mysql_store_result for show database!\n");
else
show_result_set(result_set);
}
printf("\ntables\n");
printf("------------------\n");
if(mysql_query(cnx_db,"SHOW TABLES") != 0){
printf("failure in show tables!\n");
printf("exit code 4!\n");
exit(4);
}
else {
result_set=mysql_store_result(cnx_db);
if(result_set == NULL)
printf("failure in mysql_store_result for show tables!\n");
else
show_result_set(result_set);
}
/*******************************************************************/
printf("\nrows\n");
printf("------------------\n");
if(mysql_query(cnx_db,"select * from userInfo where userID=1000") != 0){
printf("failure in show rows!\n");
printf("exit code 5!\n");
printf("Error:%u -- %s\n",mysql_errno(cnx_db),mysql_error(cnx_db));
exit(5);
}
else {
result_set=mysql_store_result(cnx_db);
if(result_set == NULL)
printf("failure in mysql_store_result for show rows!\n");
else
show_result_set(result_set);
}
/*******************************************************************/
mysql_close(cnx_init);
/*mysql_close(cnx_db);*/
printf("terminating!\n");
exit(0);
}
/************void show_result_set()***********/
void show_result_set(MYSQL_RES *in_result_set){
while((row = mysql_fetch_row(in_result_set)) != NULL){
for(ctr=0;ctr<mysql_num_fields(in_result_set);ctr++){
if(ctr>0)
fputc('\t',stdout);
printf("%s\n",row[ctr] != NULL ? row[ctr] : "Null-va15");
}
fputc("\n",stdout);
}
if(mysql_errno(cnx_init) != 0){
printf("failure in mysql_ftech_row\n");
printf("exit code 7\n");
exit(7);
}
mysql_free_result(in_result_set);
}
以上是我些的代码,问题就出现在查询代码段,错误提示为:
rows
-------------
failure in show rows!
exit code 5!
Error:1017 -- Can't find file: './linq/userInfo.frm'(errorno: 13)
请问这是怎么回事?