I am extremely new for iPhone and SQLite.
I have 1 button and three textfieldsfor ID,Name and author…When I Enter ID in ID textfield and press buttton , relative name and author should be displayed in other two textboxes..I have tried to show only name field and get success but for displaying two fields it is not working..my code is:
-(IBAction)getdata:(id)sender
{
NSString *str = bid.text;
int test = [str intValue];
NSLog(@"get clicked");
[self databaseOpen];
NSString *getData = [NSString stringWithFormat:@"SELECT Name,Author FROM
stud WHERE ID = %d",test];
NSLog(@"getdata %@",getData);
NSArray *array = [adddatabase executeQuery:getData];
[adddatabase executeQuery:getData];
getData = [[array objectAtIndex:0]valueForKey:@"Name"];
NSLog(@"update query:%@",getData);
get.text = [NSString stringWithFormat:@"%@",getData];
NSString *authordata = [[NSString alloc]init];
authordata = [[array objectAtIndex:1]valueForKey:@"Author"];
NSLog(@"author: %@",authordata);
author.text=[NSString stringWithFormat:@"%@",authordata];
}
help me…my program is getting stopped after NSLOG(@”update query : %@”,getData); and Signal abort is shown.
why you allocating
NSStringinstead of that directly use this and there is one more error you are getting only record from the database where you are writing[array objectAtIndex:1]this gives you errorTry this