如题-----
/**更新某行某列的数据**/
char *sql10="update test_table set age='28',hight='203' where name='ll'";
int tem10=sqlite3_exec(db,sql10,call_back,0,&errmsg);
if(tem10!=SQLITE_OK)
perror("sqlite3_errmsg");
在这里的疑问是,假如我从缓冲区中read(fd,buff,leangth);
假如 我要将buff里的字符内容更新到数据库中,(
char *sql10="update test_table set age='28',hight='203' where name='ll'";//就是怎么把这里的‘28’和‘203’怎么替换成buff里的内容啊,通过什么途径来来替换,才能让sql执行语句不是像上面不是自己输入进去的那样)
------解决方案--------------------------------------------------------
字符串累加生成SQL语句的方法
将read(fd,buff,leangth)取得的内容赋值变量,生成SQL语句再执行
char *sql10="update test_table set age='"+变量+"'".....
------解决方案--------------------------------------------------------
没有其他的方法,与你的方法相似
------解决方案--------------------------------------------------------
sprintf(sql11,"update test_table set age='%d',hight='%d' where name='ll'",updatechar[0],updatechar[1]);
没什么好办法,只能是拼接字符串。 不是 sprintf就是 strcpy