2012-03-24 13 views
0

テーブル列のsqlite3値を配列に保存する方法。テーブル列の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; 
    } 
+0

あなたは、データベースからqt.casesに値を取得?そして、その値が配列に格納したいされていますか? – Bhoomi

+0

はい私はデータベースからqt.casesの値を取得していますが、その値を配列に格納したい – user801222

+0

なぜもう一度質問を追加しましたか?すでにhttp://stackoverflow.com/questions/9820119/save-value-of-queryに投稿されています – hchouhan02

答えて

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]); 
        
    } 
関連する問題