hey guys this is my code for retrieving data from Sqlite3 data base queryStatementNS = [NSString stringWithFormat:@"select Propertytbl.stree_no,Propertytbl.street_name,Propertytbl.suburb,Propertytbl.pcode,(select count(pid) from Propconpertbl where pid = Propertytbl.pid ), (select count(pid) from PropFeedtbl where pid = Propertytbl.pid ) from Propertytbl Group By Propertytbl.pid;"];
const char *queryStatement = [queryStatementNS UTF8String];
// NSLog(queryStatementNS); dbrc = sqlite3_prepare_v2 (database, queryStatement, -1, &dbps, NULL); // NSLog (queryStatementNS);
if ((dbrc = sqlite3_step (dbps)) == 100) {
while(sqlite3_step(dbps)==SQLITE_ROW) {
NSString *AddressString1 = [[NSString alloc]initWithCString:(char*)sqlite3_column_text(dbps, 1)];
NSString *AddressString2 = [[NSString alloc]initWithCString:(char*)sqlite3_column_text(dbps, 2)];
NSString *AddressString3 = [[NSString alloc]initWithCString:(char*)sqlite3_column_text(dbps, 3)];
NSString *AddressString4 = [[NSString alloc]initWithCString:(char*)sqlite3_column_text(dbps, 4)];
NSString *AddressString = [[NSString alloc]initWithFormat:@"%@ %@ %@ %@",AddressString1,AddressString2,AddressString3,AddressString4];
[DATABASEARRAY addObject:AddressString];
int ContactCount = sqlite3_column_int(dbps, 5);
NSString *contactstring = [[NSString alloc]initWithFormat:@"Contact(%d)",ContactCount];
[DATABASEARRAY addObject:contactstring];
int FeedCount = sqlite3_column_int(dbps, 6);
NSString *Feedstring = [[NSString alloc]initWithFormat:@"FeedBack(%d)",FeedCount];
[DATABASEARRAY addObject:Feedstring];
[DATABASEARRAY retain];
}
but this does not returning the Count of record all other things go well what is wrong with this. while in the below function it is returning the count -(int)PropertyKey { char *select = "Select COUNT(pid) from Propertytbl;";
if (sqlite3_prepare_v2(database, select, -1, &addStmt, nil) == SQLITE_OK) {
while(sqlite3_step(addStmt)==SQLITE_ROW){
int count = sqlite3_column_int(addStmt, 0);
sqlite3_reset(addStmt);
sqlite3_finalize(addStmt);
return count;
}
}
}
i have also set the indexed from 0 to 5 but not succeeded i thought may be due to this but it not working