samedi 7 février 2015

Incorrect Insert SQLite statement

The following sql statement is incorrect and it has to do with the ? for the INSERT into ? according to my NSLog.. how do I fix this? I have an String value that holds the name of the table name



NSString *sql = [NSString stringWithFormat:@"INSERT INTO ? ('DateTime','PhotoOne','PhotoTwo','PhotoThree','Date','Time','Species','Weight','Length','Girth','Bait','Temp','WaterTemp','WeatherCondition','WaterClarity','Notes') VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"];

const char *insertStmt = [sql UTF8String];
sqlite3_stmt *sqlStatement;
int res;

if ((res = sqlite3_prepare_v2(db, insertStmt, -1, &sqlStatement, NULL)) == SQLITE_OK) {

//if doesn't fail

} else {

NSLog(@"Wrong statement: %d - %s", res, sqlite3_errmsg(db));

}


This is what the log spits out..


Wrong statement: 1 - near "?": syntax error


Aucun commentaire:

Enregistrer un commentaire