簡體   English   中英

iPhone sqlite准備錯誤

[英]iPhone sqlite prepare error

我嘗試在iPhone和所有其他工作上插入語句,但我嘗試這一個,然后我嘗試綁定值但我得到錯誤21,似乎發生因為stmt變量是在准備0x00之后(我認為是null)但不知道發生了什么

sqlite3 *database;
        sqlite3_open([pathDb UTF8String], &database);        
        sqlite3_stmt *stmt;

        NSString *insert = @"";
        if ([model.ident intValue] != -1)
        {
            insert = @"UPDATE Blubb SET Key=? WHERE Id = ?";
        }
        else
        {
            insert = @"INSERT INTO Blubb (Id, Field,KeyLastUpdate,SortNr) VALUES (?,NULL,date('now'), SELECT COUNT(*) + 1 FROM Connections)";
        }
        const char *insertStmt = [insert UTF8String];


        int result = sqlite3_prepare(database, insertStmt, -1, &stmt, NULL);

直接在SQLite中使用C函數是一種痛苦......曾經考慮過使用包裝器嗎?

自從我開始使用一個以來,我開始使用DB查詢的問題少得多......這是一個建議的鏈接:

適用於iPhone的SQLite最佳Cocoa / Objective-C包裝庫

希望能幫助到你

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM