SQLStatement is getting rejected

I'm trying to insert a user note into a sqliteDB through this method but for some reason, its not passing this if statement...

if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK){}

I'm not sure but I think my SQLStatement is getting rejected or some reason.

(void) insertQuickNoteInDataBase:(NSString *)name :(NSString *)note{
sqlite3 * database;

if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
    const char *sqlStatement = "insert into detail(QuickNote) values (?), where name = ?";
    sqlite3_stmt *compiledStatement;
    if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {

        sqlite3_bind_text(compiledStatement, 8, [note UTF8String], -1, SQLITE_TRANSIENT);
        sqlite3_bind_text(compiledStatement, 2, [name UTF8String], -1, SQLITE_TRANSIENT);

        if(SQLITE_DONE != sqlite3_step(compiledStatement))
            NSAssert1(0, @"Error while inserting data. '%s'", sqlite3_errmsg(database));


You need to log the error using sqlite3_errmsg. But the problem is most likely the comma in the query as well as the where clause. Insert statements should not have a where clause. Perhaps you mean to use an update:

"UPDATE detail SET QuickNote = ? WHERE name = ?"

Also, your calls to sqlite3_bind_xxx need to have the proper indexes. The bind indexes start at 1 and go up. You are using 8 then 2. You want 1 then 2.

Need Your Help

Paste an image from the Clipboard into Excel

excel excel-vba

I have an excel spreadsheet that I've built as a form, I need to add in a signature to several ranges on different tabs within the workbook.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.