专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > 其他数据库

sqlite插入数据的有关问题

发布时间:2010-05-24 21:31:24 文章来源:www.iduyao.cn 采编人员:星星草
sqlite插入数据的问题
void func(char * cardtype,char * cardsn){
  /*省略不重要的内容*/

  sql = "insert into "time" VALUES(null,---,---)"
}

本人想在那个sql语句的---处动态地插入cardtype和cardsn两个字符串,无论是用 cardsn和*cardsn都不行。本程序是用C语言实现的,请问高手应该怎么办呢?本程序要实现把这两个参数写到数据库里面。



------解决方案--------------------
C/C++ code

char szcharSql[MAX_PATH];

sprintf(szcharSql,
        "Insert Into t_Table1(FCardType, FCardSN)VALUES(%s, %s)",
        cardtype,
        cardsn);
              
Excute SQL...

------解决方案--------------------
Formatted String Printing Functions
char *sqlite3_mprintf(const char*,...);
char *sqlite3_vmprintf(const char*, va_list);
char *sqlite3_snprintf(int,char*,const char*, ...);
char *sqlite3_vsnprintf(int,char*,const char*, va_list);


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().
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: