I am working on an example project using X Code 4.4.1 and even though what I 
have entered is the same as what is printed this one section of code is not 
working. I would appreciate any input as to what is causing my Sqlite3_Prepare 
to spit out this error. I have included the section of code in Question.



- (void) findContact
{
    
    sqlite3_stmt *statement;
    const char *dbpath = [databasePath UTF8String];
    
    
    if (sqlite3_open(dbpath, &contactDB) == SQLITE_OK)
    {
        NSString *querySQL = [NSString stringWithFormat: @"SELECT address, 
phone, FROM contacts WHERE name = \"%@\"", name.text];
        
    const char *query_stmt = [querySQL UTF8String];
        
    if (sqlite3_prepare_v2(contactDB, query_stmt, -1, &statement, NULL) == 
SQLITE_OK)
    {
        if (sqlite3_step(statement) == SQLITE_ROW)
        {
            NSString *addressField = [[NSString alloc] initWithUTF8String: 
(const char *) sqlite3_column_text(statement, 0)];
            address.text = addressField;
            
        NSString *phoneField = [[NSString alloc] initWithUTF8String:(const char 
*) sqlite3_column_text(statement, 1)];
            phone.text = phoneField;
            
        status.text = @"Match Found";
    } else {
        status.text = @"Match not found";
        address.text = @"";
        phone.text = @"";
    }
    sqlite3_finalize(statement);
    }
        sqlite3_close(contactDB);

        NSLog(@" error '%s", sqlite3_errmsg(contactDB) );
    }
}

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to