Objective c 无法将数据插入sqlite数据库;为什么不呢?

Objective c 无法将数据插入sqlite数据库;为什么不呢?,objective-c,sqlite,Objective C,Sqlite,我想将数据保存到sqlite数据库,但它不起作用 // Setup the database object sqlite3 *database; // Open the database from the users filessytem if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) { // Setup the SQL Statement and comp

我想将数据保存到sqlite数据库,但它不起作用

// Setup the database object
    sqlite3 *database;

    // Open the database from the users filessytem
    if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
        // Setup the SQL Statement and compile it for faster access
        const char *sqlStatement =  "INSERT INTO INCOMPLETECLAIM ( provideName,claimAmount, serviceType, receipentName, serviceStart, serviceEnd) VALUES(?, ?, ?, ?, ?, ?)";

        sqlite3_stmt *compiledStatement;
        if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) 
        {
            // Loop through the results and add them to the feeds array
            sqlite3_stmt *compiledStatement;                
            if (sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK){
                //sqlite3_bind_text(compiledStatement, 1, [serStatus UTF8String], -1, SQLITE_TRANSIENT);
                NSLog(@"testtt");

              sqlite3_bind_text(compiledStatement, 2, [prName UTF8String], -1, SQLITE_TRANSIENT);
              sqlite3_bind_text(compiledStatement, 3, [prAmnt UTF8String], -1, SQLITE_TRANSIENT);
              sqlite3_bind_text(compiledStatement, 4, [gTps UTF8String], -1, SQLITE_TRANSIENT);
              sqlite3_bind_text(compiledStatement, 5, [gRecipent UTF8String], -1, SQLITE_TRANSIENT);
              sqlite3_bind_text(compiledStatement, 6, [gSSFSS UTF8String], -1, SQLITE_TRANSIENT);
              sqlite3_bind_text(compiledStatement, 7, [myString UTF8String], -1, SQLITE_TRANSIENT);
            }
        }
        // Release the compiled statement from memory
        sqlite3_finalize(compiledStatement);
    }
    sqlite3_close(database);

我做错了什么?

您必须使用sqlite3\u步骤执行语句,如下所示:

sqlite3_step(compiledStatement);

什么不起作用?是否报告了任何错误?您的数据库位于哪里?(如果您试图更改项目中包含的DB,而不先将其移动到可写目录,则更新将不会“执行”。)找出是什么,并将其添加到问题中。我注意到,出于某种原因,您在bindText中以2开始索引值。这似乎不对。第一个
是索引1,最大索引应该是6。而且您从未实际执行过sqlite3\u stmt(使用sqlite3\u步骤)。它不会显示任何错误报告