Hi guys
I am developing an app that uses sqlite to store info about hotels. The table in the sqlite db is very simple, id, name, address.
I tried this sql using firefox Sqlite manager
select hotels.name,hotels.address from hotels where hotels.name like '%%hotel%%'
and I get the results
if I use this code it gives me no results at all
-(NSMutableArray*)searchString
{
NSMutableArray *ar1=[[[NSMutableArray alloc]init]autorelease];
int count = 0;
sqlite3_stmt *selectstmt;NSString *query = [NSString stringWithFormat:@"select hotels.name,hotels.address from hotels where hotels.name like '%%hotel%%'"];
NSLog(@"query %@ ", query);
const char * sql = [query UTF8String];
if (sqlite3_prepare_v2(database, sql, -1, &selectstmt, NULL) == SQLITE_OK)
{
while(sqlite3_step(selectstmt) == SQLITE_ROW)
{
element *x=[[element alloc]init];
x.name = [NSString stringWithUTF8String

char*)sqlite3_column_text(se lectstmt, 1)];
x.address = [NSString stringWithUTF8String

char*)sqlite3_column_text(se lectstmt, 2)];
}
}
}
if I change the sql query in select * from hotels' it works pefectly
-(NSMutableArray*)searchString
{
NSMutableArray *ar1=[[[NSMutableArray alloc]init]autorelease];
int count = 0;
sqlite3_stmt *selectstmt;NSString *query = [NSString stringWithFormat:@"select * from hotels'"];
NSLog(@"query %@ ", query);
const char * sql = [query UTF8String];
if (sqlite3_prepare_v2(database, sql, -1, &selectstmt, NULL) == SQLITE_OK)
{
while(sqlite3_step(selectstmt) == SQLITE_ROW)
{
element *x=[[element alloc]init];
x.name = [NSString stringWithUTF8String

char*)sqlite3_column_text(se lectstmt, 1)];
x.address = [NSString stringWithUTF8String

char*)sqlite3_column_text(se lectstmt, 2)];
}
}
}
I wonder if there are some limitations on the query
thanks for your time