I am trying to create login page in my application. For that I am using sqlite database(journeymapper.db3 it is database name) which has UserInformation table
For that use the fowling code:
-(void)checkindatabase
{
NSString *direct = [[NSString alloc]init] ;
NSString *dbPath = [direct stringByAppendingPathComponent:@"journeymapper.db3"];
if(sqlite3_open([dbPath UTF8String], &database) == SQLITE_OK)
{
NSLog(@"open");
NSString *sql = [[NSString alloc] initWithFormat:@"select Username='%@',Password='%@' from UserInformation",txtuser.text,txtpass.text];
//[sql UTF8String];
//NSLog(@"'%s'",[sql UTF8String]);
sqlite3_stmt *statment;
if(sqlite3_prepare_v2(database, [sql UTF8String], -1, &statment, NULL) == SQLITE_OK)
{
if(sqlite3_step(statment) == SQLITE_ROW)
{
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:nil
message:@"Welcome to joureny" delegate:nil
cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
}
sqlite3_finalize(statment);
}
sqlite3_close(database);
}
-(IBAction)login
{
[self checkindatabase];
}
I am entering right user name & password but it doesn’t show me the alertview how can I achieve this. Please help me on how I can create the login page.
May be 2 of ur assignment are incorrect.1. check dbpath and query
1.
2.
Change Your query as
if it return some thing …Your username and password is correct .or else one of the text is in correct
Edited Answer
Best Regards,