javascript - how to pass parameters in sqlite transaction in cordova -


I have a bookd and I have to pass it on sqlite transactions in Cordova

 var bookName = Db.transaction (function (tx) {return tx.executeSql ('SELECT * FROM Iqra_Book WHERE book_id =?', [1], function (tx, ridge) {var leng = res.rows.length; console.log (" Length: "+ leng); return bkName = res.rows.item (0) .book_name;}, function (e) {return console.log (" error: "+ e.message);});});  

But I'm receiving this booName as undefined. Can somebody help me out?

You have to pass a variable in the book id, leave the "return" Only works by asynchronon can return only one value

  tx.executeSql ('SELECT * FROM Iqra_Book WHERE book_id = "' + + '+' '', [1] Also, change the line  
  bkName = res.rows [0]. Book_name;    Pre> 

to

  back bkName = results.rows.item [0] .book_name;   

and check that it works

Comments