开发者

sqlite3_bind_text for null string

I use the codes to access sqlite

sqlite3_bind_text(statement,1,[myString UTF8String],-1,SQLITE_TRANSIENT);

It works. But if myString is NULL, it always causes updatin开发者_如何学运维g the record in table failed. (or nothing changed) How to process when myStrign is NULL?

Welcome any comment

Thanks


Use sqlite3_bind_null(statement, 1); when your string is NULL.

if (myString)
    sqlite3_bind_text(statement,1,[myString UTF8String],-1,SQLITE_TRANSIENT);
else 
    sqlite3_bind_null(statement,1);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜