mardi 26 avril 2016

sql.js - searching the text fields

I am trying to search a text field of a sqlite DB using sql.js, but keep getting this error:

Error: no such column: LOTR sql.js:447:501

(here LOTR is just a example keyword)

Back Trace:

Nd.prototype.handleError() sql.js:447

Nd.prototype.prepare() sql.js:447

Nd.prototype.exec() sql.js:446

Book/this.show_result() sqlite.js:24

onkeyup() book:1

index.html:

<input name="keyword" id="keyword" placeholder="Search" onKeyUp="hd.show_result($(this).val());" />

sqlite.js: (a part of Book class)

this.show_result = function(keyword, bypass){
    this.keyword = keyword.trim();
    var result_set = $(".result_set");
    result_set.html("");
    if (!bypass){
        var result = db.exec("SELECT BookID, BookName FROM book WHERE BookName LIKE '%" + this.keyword + "%'");
        if(result[0].values[0][0]) {
            result_set.append("<h3>Books</h3>");
            result = result[0].values;
            for (var i = 0; i < result.length; i++) {
                result_set.append("<a class='result' onclick='hd.get_sections(" + result[i][0] + ")' href='#'>" + result[i][1] + "</a>");
            }
        }
    }
};

PS: I have tried the same code with a int field, which is working fine while searching in any text field returns the same error as above.

Aucun commentaire:

Enregistrer un commentaire