These routines are work-alikes of the "printf()" family of functions from the standard C library.
The sqlite3_mprintf() and sqlite3_vmprintf() routines write their results into memory obtained from sqlite3_malloc(). The strings returned by these two routines should be released by sqlite3_free().
sprintf(szcharSql,
"Insert Into t_Table1(FCardType, FCardSN)VALUES(%s, %s)",
cardtype,
cardsn);
Excute SQL...
[/Quote]
还是不行啊,我给你写详细点吧,你再指点我一下。
void Func(unsigned char *cardtype,unsigned *cardsn){
char *sql = "create table time (ID INTEGER PRIMARY KEY ,SensorID TEXT,SiteNum TEXT);";
//sql = "insert into time VALUES(NULL,cardtype,cardsn);";//这种方法传不进去
//fprintf(sql,"insert into time (SensorID,SiteNum)VALUES(NULL,%s,%s)",cardtype,cardsn);//这是你的方法,可也是不行的,和上面的结果是一样的
sql = "insert into time VALUES(NULL,'aa','bb');";//这样就能存到数据库里面
}
void Func(unsigned char *cardtype,unsigned *cardsn){
char *sql = "create table time (ID INTEGER PRIMARY KEY ,SensorID TEXT,SiteNum TEXT);";
//sql = "insert into time VALUES(NULL,cardtype,cardsn);";//这种方法传不进去
//fprintf(sql,"insert into time (SensorID,SiteNum)VALUES(NULL,%s,%s)",cardtype,cardsn);//这是你的方法,可也是不行的,和上面的结果是一样的
sql = "insert into time VALUES(NULL,'aa','bb');";//这样就能存到数据库里面
}