tags:

views:

22

answers:

1

I want to get fields name from the sqlite database in my mac desktop application.How it possible please help me.

A: 

If you're using the SQLite C API directly (which you shouldn't), you can use the sqlite_column_name() function to get the name of a column for a given index. This works well with the sqlite_column_count() function.

If you're using the Flying Meat Database wrapper (which you should), you can execute PRAGMA table_info(myTable), and then iterate through the ResultSet. The column name is at index 1. In other words:

FMResultSet * infoRS = [db executeQuery:@"PRAGMA table_info(myTable)"];
while ([infoRS next]) {
    NSLog(@"Column #%d: %@", [infoRS intForColumnIndex:0], [infoRS stringForColumnIndex:1]);
}
Dave DeLong