这是我的代码我试图在我的数据库中插入ma,但错误发生在: 函数的参数太多' int mysql_query(MYSQL *,const char *)' 注释在mysql.h中声明 mysql.h中的行:int STDCALL mysql_query(MYSQL * mysql,const char * q);
while(true)
{
mysql_query(conn, " select close, id from fivemin order by id DESC LIMIT 5 ");
result = mysql_store_result(conn);
num_fields = mysql_num_fields(result);
float sum = 0;
while((row=mysql_fetch_row(result)))
{
sum += atof(row[0]);
last_id = atoi(row[1]);
}
float ma;
ma=sum/5.0;
if(previous_last_id != last_id)
{
cout << "Simple moving Average: " << ma << endl;
previous_last_id = last_id;
}
mysql_query(conn,("insert into sma values('%f')"),ma);
Sleep(1000);
}
答案 0 :(得分:1)
mysql_query(conn,("insert into sma values('%f')"),ma)
有三个参数。
您需要在致电mysql_query.
示例:
char str[80];
sprintf(str, "insert into sma values('%f')", ma);
mysql_query(conn, str);