mysql_query(&mydata1,sqlstr1)时提示读取字符串的字符时出错 求解这是为什么????
这是源码inti=0;inta,b,d;intj,k;inti1=1,i2=0,a1;MYSQLmydata1;charsqlstr1[1024];intlen1=spr...
这是源码
int i = 0; int a, b, d; int j, k; int i1=1, i2 = 0, a1;
MYSQL mydata1;
char sqlstr1[1024];
int len1=sprintf_s(sqlstr1,256, "SELECT *FROM touristpoint;");
cout << len1;
cout << sqlstr1 << endl;
mysql_query(&mydata1, sqlstr1);//读取字符串出错
MYSQL_RES *result1 = NULL;
result1 = mysql_store_result(&mydata1);
int rowpoint = mysql_num_rows(result1);
c.vexnum = rowpoint;
unsigned int fieldcount1 = mysql_num_fields(result1);
MYSQL_FIELD *field1 = NULL;
for (unsigned int i = 0; i < fieldcount1; i++) {
field1 = mysql_fetch_field_direct(result1, i);
}
MYSQL_ROW row1 = NULL;
row1 = mysql_fetch_row(result1);
while (NULL != row1&&i1<rowpoint)
{
while (i2<fieldcount1)
{
a1 = atoi(row1[i2]); i2++;
c.vexs[i1].position = a1;
strcpy(c.vexs[i1].name, row1[i2]);
strcpy(c.vexs[i1].introduction, row1[i2]);
}
i2 = 0;
i1++;
row1 = mysql_fetch_row(result1);
} 展开
int i = 0; int a, b, d; int j, k; int i1=1, i2 = 0, a1;
MYSQL mydata1;
char sqlstr1[1024];
int len1=sprintf_s(sqlstr1,256, "SELECT *FROM touristpoint;");
cout << len1;
cout << sqlstr1 << endl;
mysql_query(&mydata1, sqlstr1);//读取字符串出错
MYSQL_RES *result1 = NULL;
result1 = mysql_store_result(&mydata1);
int rowpoint = mysql_num_rows(result1);
c.vexnum = rowpoint;
unsigned int fieldcount1 = mysql_num_fields(result1);
MYSQL_FIELD *field1 = NULL;
for (unsigned int i = 0; i < fieldcount1; i++) {
field1 = mysql_fetch_field_direct(result1, i);
}
MYSQL_ROW row1 = NULL;
row1 = mysql_fetch_row(result1);
while (NULL != row1&&i1<rowpoint)
{
while (i2<fieldcount1)
{
a1 = atoi(row1[i2]); i2++;
c.vexs[i1].position = a1;
strcpy(c.vexs[i1].name, row1[i2]);
strcpy(c.vexs[i1].introduction, row1[i2]);
}
i2 = 0;
i1++;
row1 = mysql_fetch_row(result1);
} 展开
1个回答
2017-06-25
展开全部
"SELECT *FROM touristpoint;" 去掉语句里的;分号
追问
嗯好的,谢谢了,已经解决了。这和我在程序开头声明的一个MYSQL类型的全局变量有关,把这个函数里面的mydata1换成那个全局变量就好了,谢谢了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询