tags:

views:

26

answers:

1

Hi,

Currently I am getting the values from statement like this:

[[NSString stringWithUTF8String:(char *)sqlite3_column_text(ReturnStatement,0)] retain];

I want to get the values by entering the column name like this:

[[NSString stringWithUTF8String:(char *)sqlite3_column_text(ReturnStatement,@"FirstColumn")] retain];

Is there any way to do this?

Thanks. Best Regards, Naveed Butt

A: 

Check out http://sqlite.org/c3ref/column_name.html. You will have to iterate over the column indices returned by the query to add the column names to an array or dictionary that you can reference later to lookup the column index given a name to provide to the column_text function which only accepts the column index as an integer parameter.

One of the problems of using sqlite directly instead of CoreData which will handle this for you.

falconcreek
okay thanks for your answer. :)