vendredi 16 octobre 2015

Xcode Sqlite use UITextfield to select column header

This section of code works great, however there is the opportunity to pick total of 3 of five search choices, with this in mind, I would like to use UitextField's for the WHERE, for example replace "Chain = ?" replaced with "search.text = ?", I am familiar with "WHERE Chain=\"%@\"",_somthing.text" but can't work out how to replace the hard code column header with a UITextField,

Can any body please help

`NSString *querySQL = [NSString stringWithFormat:

                              @"SELECT FullName FROM storeDetails WHERE (Chain = ? AND Format = ? AND RegionCode = ?)"];

        const char *query_stmt = [querySQL UTF8String];
        if (sqlite3_prepare_v2(detailspapav2,
                               query_stmt, -1, &statement, NULL) == SQLITE_OK)

        {

            if (sqlite3_bind_text(statement, 1, [_choiceText1.text UTF8String], -1, NULL) != SQLITE_OK) {
                NSLog(@"Bind 1 failed");
            }
            if (sqlite3_bind_text(statement, 2, [_choiceText2.text UTF8String], -1, NULL) != SQLITE_OK) {
                NSLog(@"Bind 2 failed");
            }
            if (sqlite3_bind_text(statement, 3, [_choiceText3.text UTF8String], -1, NULL) != SQLITE_OK) {
                NSLog(@"Bind 3 failed");
            }
        }`

Aucun commentaire:

Enregistrer un commentaire