0
- (BOOL)addloginprofile:(NSString *)username andPassword:(NSString *)password
{
    //XYZAppDelegate *appDelegate = (XYZAppDelegate *)[UIApplication sharedApplication].delegate;
    //const char *sql = "select Name='%@',EnterPassword='%@' from ProfileTable";
    NSString *sql = [[NSString alloc] initWithFormat:@"select Name='%@',EnterPassword='%@' from ProfileTable",username,password];

    //NSString *sql = [NSString stringWithFormat:@"select Name='%@',EnterPassword='%@' from ProfileTable",username,password];

    NSLog(@"sql statment %@",sql);

    sqlite3_stmt *statment;
    if(sqlite3_prepare_v2(database, [sql UTF8String] , -1, &statment, NULL) == SQLITE_OK)
    //if(sqlite3_prepare_v2(database, [sql UTF8String] , -1, &statment, NULL) == SQLITE_OK)
    {
        if(sqlite3_step(statment) == SQLITE_ROW)
        {
            NSString *username=[[NSString alloc] initWithUTF8String:(const char *)       sqlite3_column_text(statment,0)];

            NSString *password=[[NSString alloc]initWithUTF8String:(const char *)sqlite3_column_text(statment,1)];
//          NSString *username = [NSString stringWithUTF8String:(char *)sqlite3_column_text(statment, 1)];
//          NSString *password=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statment, 2)];           
            NSLog(@"User name %@,",username);
            NSLog(@"password %@",password);
            if ([username isEqualToString:@"0"]&&[password isEqualToString:@"0"]) {
                return NO;
            }
            else return YES;

        }
}
4

1 に答える 1

0

クエリが適切にフォーマットされていないと思います。このようにする必要があります@"select * from ProfileTable where Name='%@' and EnterPassword='%@'",username,password

于 2012-08-03T13:03:02.813 に答える