2011-04-06 4 views
0

여기에서 선택 쿼리를 구현하여 테이블에서 데이터를 가져 오지만 내 쿼리에서는 모든 행이 반환되지 않습니다.쿼리 선택 준비 중이 없습니다.

아래 내가 사용 내 코드이다

if ((sqlite3_open([[self dataFilePath] UTF8String], &database))==SQLITE_OK) 
{ 
    NSLog(@"DataBase OpeneD..!!"); 
    imageId=[[NSMutableArray alloc] init]; 
    const char *slectImageIdQuery="SELECT * from ts_Gallary;"; 
    sqlite3_stmt *statement; 
    if (sqlite3_prepare_v2(database, slectImageIdQuery, -1, &statement, nil)==SQLITE_OK) 
    { 
     NSLog(@"Query CREATED..!!"); 
     while (sqlite3_step(statement)==SQLITE_ROW) 
     { 
      int iId=sqlite3_column_int(statement, 0); 
      NSString *imgTtl=[NSString stringWithFormat:@"%d",iId]; 
      NSLog(@"image id in while=%d",iId); 
      [imageId addObject:[NSString stringWithFormat:@"%@",imgTtl]];   
     } 
    } 
    else 
    { 
     NSLog(@"query could not be prepared"); 
    } 

    sqlite3_finalize(statement);   
} 
sqlite3_close(database); 

내 콘솔 디스플레이 44 :

2011-04-06 17 33.381 토스카 [4680 : 207] 데이터베이스가 개방 ..! ! 2011-04-06 17 : 44 : 33.382 토스카 [4680 : 207] 쿼리를 제조 할 수 없었다

주 : 여기 dataFilePath 내 데이터베이스 데이터베이스 경로를 반환 방법은이 sqlite3를 목적

아니요 응용 프로그램에서 오류 또는 예외가 발생했습니다.

어떤 문제가 있으며 어떻게 해결할 수 있습니까?

감사합니다. * slectImageIdQuery = "ts_Gallary SELECT * 「CONST 숯에서()

답변

0

내 응용 프로그램에 의해 오류 또는 예외가 발생했습니다.

글쎄, 그렇습니다. sqlite3_prepare_v2()에 대한 호출이 실패합니다. SQLITE_OK를 반환하지 않습니다.

데이터베이스의 sqlite 프롬프트에서이 명령문을 실행하면 어떻게됩니까?

SELECT * from ts_Gallary; 

당신에게 오류에 대한 자세한 정보를 제공합니다 뭔가이 줄

NSLog(@"query could not be prepared"); 

를 교체하십시오. sqlite3_errmsg() 호출을 포함하십시오.

0

세미콜론 삭제

const를 숯불처럼 * slectImageIdQuery =

과 작업 제대로 "를 ts_Gallary SELECT * FROM".