C 语言数组插入 mysql 数据库 求助
展开全部
#include <stdio.h>
#include <stdlib.h>
#include <mysql/mysql.h>
int main(int argc, char *argv[])
{
MYSQL *my_con = malloc( sizeof(MYSQL) );
MYSQL_RES *my_res;
MYSQL_FIELD *my_field;
MYSQL_ROW my_row;
int rows, i;
int res;
int a[2] = {51,2};
printf("%3d ",a[0]);
mysql_init(my_con);
my_con = mysql_real_connect(my_con, "localhost", "root", "jwn.com",
"jwn", 0, NULL, CLIENT_FOUND_ROWS);
if( NULL == my_con )
error_quit("Connection fail", my_con);
printf("Connection success\n");
res = mysql_query(my_con,
"insert into class1(name, age, birthday) value('abc', 52, NOW());");
mysql_free_result(my_res);
mysql_close(my_con);
free(my_con);
return 0;
}
#include <stdlib.h>
#include <mysql/mysql.h>
int main(int argc, char *argv[])
{
MYSQL *my_con = malloc( sizeof(MYSQL) );
MYSQL_RES *my_res;
MYSQL_FIELD *my_field;
MYSQL_ROW my_row;
int rows, i;
int res;
int a[2] = {51,2};
printf("%3d ",a[0]);
mysql_init(my_con);
my_con = mysql_real_connect(my_con, "localhost", "root", "jwn.com",
"jwn", 0, NULL, CLIENT_FOUND_ROWS);
if( NULL == my_con )
error_quit("Connection fail", my_con);
printf("Connection success\n");
res = mysql_query(my_con,
"insert into class1(name, age, birthday) value('abc', 52, NOW());");
mysql_free_result(my_res);
mysql_close(my_con);
free(my_con);
return 0;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询