开发者

how to get database fields value from the sqlite database?

I want to get fields name from the sqlite database in my mac开发者_C百科 desktop application.How it possible please help me.


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]);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜