如何在数组中保存表列sqlite3值

时间:2012-03-24 06:20:01

标签: iphone

如何在数组中保存表列sqlite3值。

tempQuery=[@"select * from iapp_tbl_cases where casenum=" 
             stringByAppendingString:[NSString stringWithFormat:@"%d",rowid]];

const char *query2=[tempQuery UTF8String];

if (sqlite3_prepare_v2(database,query2,-1,&statement,NULL)==SQLITE_OK) {

    qt=[[[Question alloc]init]autorelease];
    while (sqlite3_step(statement)==SQLITE_ROW) {
        qt.cases=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement,2)];
        return qt;
    }

1 个答案:

答案 0 :(得分:0)

Create one array and store the value as below:
NSMutableArray *arr=[[NSMutableArray alloc]init];
tempQuery=[@"select * from iapp_tbl_cases where casenum=" 
             stringByAppendingString:[NSString stringWithFormat:@"%d",rowid]];

const char *query2=[tempQuery UTF8String];

if (sqlite3_prepare_v2(database,query2,-1,&statement,NULL)==SQLITE_OK) {

    qt=[[[Question alloc]init]autorelease];
    while (sqlite3_step(statement)==SQLITE_ROW) {
        qt.cases=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement,2)];
[arr addObject:qt.cases];
 NSLog(@"arr is %@",[arr description]);
        
    }