I am working with the sqlite database and everything is going well. I added 4 entries in the table, and then added textview on my xib file. Now i want that my textview should show me these entries rendomly without repeating. I mean that whenever i run my application my textview should fetch the data from the different row which was not shown before.
Please help me out with my issue.
~~~~~~~~~~~~~~~~~~~~~~~~~ Fetching Data from table of MOtivational Thoughts ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if(sqlite3_open([databasePath UTF8String], &contactDB) == SQLITE_OK) {
const char* sql = "Select * FROM THOUGHTS";
sqlite3_stmt *compiledStatement;
if (sqlite3_prepare_v2(contactDB, sql, -1, &compiledStatement, nil)==SQLITE_OK) {
NSLog(@"Ready to enter while loop");
while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
NSString *aid = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 0)];
textView.text = aid;
}
}
sqlite3_finalize(compiledStatement);
}
sqlite3_close(contactDB);
}
In textView.text i am getting only the first row data but i want that textview should pic data from any row of the column.