My problem is that i cant get the values from the select query as it executes 101 error.
I think that my problem is that it has to be with the quotes in select statement
sqlite3 * database ;
NSString * path = [[[ NSBundle mainBundle ]resourcePath ] stringByAppendingPathComponent : @"cars.sqlite"];
int returnCode = sqlite3_open ([ path cStringUsingEncoding : NSUTF8StringEncoding], &database) ;
sqlite3_stmt * statement ;
char * st ;
NSString *querySQL = [NSString stringWithFormat: @"select brand,model from cars where brand=%@;", tmpbrand];
const char *query_stmt = [querySQL UTF8String];
st = sqlite3_mprintf (query_stmt);
if(sqlite3_prepare_v2 ( database , query_stmt , -1 ,& statement ,NULL )==SQLITE_OK){
returnCode = sqlite3_step ( statement ) ; // this statement returns a record
while ( returnCode == SQLITE_ROW ) // while there are rows
{
models*tmp=[[models alloc]init];
char* n=(char*)sqlite3_column_text(statement,0);
tmp=[NSString stringWithCString:n encoding:NSUTF8StringEncoding];
char* model=(char*)sqlite3_column_text(statement, 1);
tmp.model=[NSString stringWithCString:model encoding:NSUTF8StringEncoding];
[data addObject:tmp];
returnCode = sqlite3_step ( statement ) ; // this statement returns a record
}
sqlite3_finalize(statement);
}
}
Aucun commentaire:
Enregistrer un commentaire