what's wrong with sql statements sqlite3_column_text ??
- by ahmet732
if(sqlite3_open([databasePath UTF8String], & database) == SQLITE_OK) {
NSLog(@"DB OPENED");
// Setup the SQL Statement and compile it for faster access
const char *sqlStatement ="select name from Medicine";
sqlite3_stmt *compiledStatement;
int result = sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, nil);
NSLog(@"RESULT %d", result);
if(result == SQLITE_OK) {
NSLog(@"RESULT IS OK...");
// Loop through the results and add them to the feeds array
while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
// Read the data from the result row
NSLog(@"WHILE IS OK");
**araci = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)];**
NSLog(@"Data read");
NSLog(@"wow: %",araci);
}//while
}//if sqlite_prepare v2
// Release the compiled statement from memory
sqlite3_finalize(compiledStatement);
NSLog(@"compiled stmnt finalized..");
}
sqlite3_close(database);
NSLog(@"MA_DB CLOSED");
Questions
1 ) Everything is alright until bold code. when i run the app, throws an exception below. I have one table and one row in my db relatively, id (integer), name (varchar), desc (varchar) (I created my table using SQLite Manager).
2-) What is text type in SQLite Manager? Is that NSString? Also how can I put the string values(in table) to an NSMutableArray ? (I am really having difficulty in conversion.)
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[NSString stringWithUTF8String:]: NULL cString'