tags:

views:

21

answers:

0

Dear All,

I have a sqlite3 database which saves the images. I am trying to retrieve al the images from the database, but the statement executes once and then it throws exc_bad_access error. If i remove the while keyword and add if instead, the code works fine.Please help. The code is attached below

        if(statement=[self prepare:slctSql])
{
    while(sqlite3_step(statement)==SQLITE_ROW)
    {
        imgData=[[NSData alloc] initWithBytes:sqlite3_column_blob(statement, 1) length:sqlite3_column_bytes(statement, 1)];
        imageId=sqlite3_column_int(statement, 0);
        //NSInteger imgId=imageId;
        [imgArr addObject:[UIImage imageWithData:imgData]];
        [idArr addObject:[NSString stringWithFormat:@"%d",imageId]];
                [imgData release];
    }
}
sqlite3_finalize(statement);

Thanks