The count returns a count of the parameters and is good. However the index is returning 0.
Any ideas?
sqlite3 *database;
sqlite3_stmt *updateStmt;
int ID;
const char *sql;
sql = "update User set Name = ? , Dev = ?,ActiveLevel = ? Where _id = ?";
if(sqlite3_prepare_v2(database, sql, -1, &updateStmt, NULL) != SQLITE_OK)
NSAssert1(0, @"Error while creating update statement. '%s'", sqlite3_errmsg(database));
NSLog(@"count %d",sqlite3_bind_parameter_count(updateStmt));
NSLog(@"Index %d",sqlite3_bind_parameter_index(updateStmt,"ActiveLevel"));
From the fine manual:
And for parameters:
Emphasis mine in the second section.
Your SQL doesn’t have any named parameters at all, you just have plain old placeholders. The parameter name is the name of the placeholder (
:AAAA), not the name of the column in question; remember that you can use placeholders in places where no name could be automatically derived so you have to name them yourself.If you want to use
ActiveLevelas a named parameter, then your SQL should look like this:And you’d probably want to replace the other placeholders (
?) with named parameters for consistency.