Update Query using the Objective C Wrapper for sqlite
Hey I am using the http://th30z.netsons.org/2008/11/objective-c-sqlite-wrapper/ wrapper .
My code is this :
- (IBAction)UpdateButtonPressed:(id)sender
{
Sqlite *sqlite = [[Sqlite alloc] init];
NSString *writableDBPath = [[NSBundle mainBundle]pathForResource:@"Money"ofType:@"sqlite"];
if (![sqlite open:writableDBPath])
return;
NSArray *query = [sqlite executeQuery:@"UPDATE UserAccess SET Answer ='Positano';"];
NSDictionary *dict = [query objectAtIndex:2];
NSString *itemValue = [dict objectForKey:@"Answer"];
NSLog(@"%@",itemValue);
}
Answer is the Column name , UserAccess the table name . the column is at 3rd place in the table
What am I doing wron开发者_如何转开发g why is it crashing ???
@"UPDATE UserAccess SET Answer ='Positano';"];
NSArray *query2 = [sqlite executeQuery:@"SELECT Answer FROM UserAccess;"];
NSDictionary *dict = [query2 objectAtIndex:0];
NSString *itemValue = [dict objectForKey:@"Answer"];
An update query does not return any results. You will typically use objectAtIndex
after executing a SELECT query, but it won't work with UPDATE.
精彩评论