小编Vic*_*tor的帖子

SQLITE3插入一个空值

sqlite3_bind_int(statement, 1, nil);
Run Code Online (Sandbox Code Playgroud)

我怎样才能null在上面的语句中添加一个,因为我正在使这个字段自动增加.

这是我的代码:

if (sqlite3_open([[self dataFilePath] UTF8String], &database)!= SQLITE_OK) 
 {
 sqlite3_close(database);
 NSAssert(0, @"Failed to open database");
 }
NSLog(@"json count ========== %i",[jsonArray count]);
    for (int i =0 ; i < [jsonArray count]; i++) 
    // while (i < [jsonArray count])
{ 
 dictionary = [jsonArray objectAtIndex:i];
 char *errorMsg;

 sqlite3_stmt *statement;
 if(sqlite3_prepare_v2(database, [insertQuery UTF8String], -1, &statement, nil) == SQLITE_OK) 
 {
 // NSLog(@"%@",[dictionary valueForKey:@"text"]);
 sqlite3_bind_null(statement, 1);
 sqlite3_bind_text(statement, 2, [[dictionary valueForKey:@"date"] UTF8String], -1, NULL);
    // NSLog(@"date %@",[dictionary valueForKey:@"date"]);

 sqlite3_bind_text(statement, 3, [[dictionary valueForKey:@"text"] …
Run Code Online (Sandbox Code Playgroud)

sqlite ipad ios4

2
推荐指数
1
解决办法
4530
查看次数

标签 统计

ios4 ×1

ipad ×1

sqlite ×1