Hello All,

I am having trouble reading the second table from my database because it 
returns nothing even if there is data inside it.

I have a function below

- (NSMutableArray*) getRegions
{
    NSMutableArray * data = [[NSMutableArray alloc] init];
    const char * sql = "SELECT * FROM Regions ORDER BY RegionName";
    sqlite3_stmt * statement;
    
    //prepare the select statement
    int returnValue = sqlite3_prepare_v2(mDatabase, sql, -1, &statement, NULL);
    
    DebugLog("return value = %d\n",returnValue);
    
    if (returnValue == SQLITE_OK)
    {
        //loop all the rows returned by the query
        while (sqlite3_step(statement) == SQLITE_ROW)
        {
            
            //get the name and the score
            int  iDen = sqlite3_column_int(statement, 0);
            NSString* name = [NSString stringWithUTF8String:(char 
*)sqlite3_column_text(statement, 1)];
            
            
            
            DebugLog("ColumnName = %s\n",[name UTF8String]);
            DebugLog("ColumnID %d\n",iDen);
            
            [data addObject:[NSDictionary dictionaryWithObjectsAndKeys:name, 
REGION_NAME, [NSNumber numberWithUnsignedInt:iDen], REGION_ID, nil]];
            
            
        }
        
    }
    
    sqlite3_finalize(statement);


    return [data autorelease];
}

and it works fine but then when I call the second function below after 
performing the above function,

- (NSMutableArray*) getProvinces
{
    NSMutableArray * data = [[NSMutableArray alloc] init];
    const char * sql = "SELECT * FROM Provinces";
    sqlite3_stmt * statement;
    
    //prepare the select statement
    int returnValue = sqlite3_prepare_v2(mDatabase, sql, -1, &statement, NULL);
    
    DebugLog("return value = %d\n",returnValue);
    
    if (returnValue == SQLITE_OK)
    {
        //sqlite3_bind_int(statement, 1, regionID);
        //loop all the rows returned by the query
        while (sqlite3_step(statement) == SQLITE_ROW)
        {
            
            //get the name and the score
            int  iDen = sqlite3_column_int(statement, 0);
            NSString* name = [NSString stringWithUTF8String:(char 
*)sqlite3_column_text(statement, 0)];
            int recordIden = sqlite3_column_int(statement, 2);
            
            DebugLog("ColumnName = %s\n",[name UTF8String]);
            DebugLog("ColumnID %d\n",iDen);
            
            [data addObject:name];
            
            
        }
        
    }
    
    sqlite3_finalize(statement);
    
    
    return [data autorelease];
}

I get nothing



      Get your new Email address!
Grab the Email name you've always wanted before someone else does!
http://mail.promotions.yahoo.com/newdomains/aa/
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to