Hopefully my question has a simple solution. I am just starting to use sqlite3 and I have created a database called local and a table called table with 1 column called name with type text.
It connects to the database fine its just I am trying to input a string value into the tables column but I think there is an issue with my INSERT text. I know its probably something simple if anyone could just let me know where I went wrong. Thanks.
SString *inserStmt = [NSString stringWithFormat:@"INSERT INTO TABLE(NAME) VALUES ('%s')", [key UTF8String]];
const char *insert_stmt = [inserStmt UTF8String];
sqlite3_exec(database, insert_stmt, NULL, NULL, NULL);
Your first problem is that you ignore any errors and don’t display the error message, so if something goes wrong, you will have no clue.
Your second problem is that
TABLEis a keyword;to use it as a name in SQL statements, you have to escape it with double quotes: