Я думаю, что имя пользователя и пароль совпадают только для одного пользователя, так как если оно совпадает, то вернется одна строка, используя следующий кодПроверьте следующий код, я думаю, это будет работать для вас.
-(void)checkingDatabase{
databaseName = @"trylogin.sqlite";
// Get the path to the documents directory and append the databaseName
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [documentPaths objectAtIndex:0];
databasePath = [[documentsDir stringByAppendingPathComponent:databaseName]retain];
NSLog(@"databse path %@",databasePath);
database = nil;
int myInt = 0;
if(sqlite3_open([databasePath UTF8String], &database) ==SQLITE_OK){
NSString *sql = [[NSString alloc] initWithFormat:@"select COUNT(*) from loginTry where userName='%@' and password='%@'",txtusername.text,txtPassword.text];
const char *sqlStatement = [tempSQL cStringUsingEncoding:NSUTF8StringEncoding];
[tempSQL release];
sqlite3_stmt *compiledStatement;
sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL);
if(sqlite3_step(compiledStatement) == SQLITE_ROW) {
myInt = (int)sqlite3_column_int(compiledStatement, 0);
}
sqlite3_finalize(compiledStatement);
sqlite3_close(database);
}
if(myInt ! = 0){
AnimalViewController *FBController = [[AnimalViewController alloc] initWithNibName:@"AnimalViewController" bundle:nil];
[self.view addSubview:FBController.view];
}
else
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"UIAlertView" message:@"Wrong username or password" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil];
[alert show];
[alert release];
}
}