1

My SQLite field is a numeric type (int). When i try to extract it into my application like this:

int id_quiz= (NSInteger) sqlite3_column_text(statement, 0);

i got a huge value like 129600224 which is not the correct one (and it changes every time i run the app).

However, in the same table, i got string value from other fields just fine:

NSString *question = [[NSString alloc] 
                                          initWithUTF8String:
                                          (const char *) sqlite3_column_text(
                                                                             statement, 1)];

The question is, how can i get a numeric value from SQLite? Thanx in advance.

0

2 Answers 2

3

Try this:

int id_quiz =sqlite3_column_int(statement, 0);

for more information SQLite

Sign up to request clarification or add additional context in comments.

Comments

2

You need to fetch the column as an int, not as "text":

int id_quiz = sqlite3_column_int(statement, 0);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.