How can I insert variable value in Sqlite, I am unable to find the issue with my code, If I use insert statement as follows it is working and values are inserted,
tx.executeSql('INSERT INTO Locationlog (Coordinates, Location, Category, Address) VALUES ("manju", "kishor", "ramesh", "ram")');
If I try to insert as follows the values are not inserted,
tx.executeSql('INSERT INTO Locationlog (Coordinates, Location, Category, Address) VALUES (?,?,?,?)',[Latlongs,Location,Category,Address]);
does not work for the query like,
tx.executeSql('INSERT INTO Locationlog (Coordinates, Location, Category, Address) VALUES ('+Latlongs+', '+Location+', '+Category+', '+Address+')');
I am using TEXT as datatype for all columns, the input value size is in between 1-100. What is the maximum size for TEXT data type? Any one can suggest how to insert variables in insert query ?
var Latlongs = $("#defendLatlongs").val();
var Location = $("#defendLocation").val();
var Category = $("#defendcategory").val();
var Address = $("#defendAddress").val();
var db = window.sqlitePlugin.openDatabase({name: "MYDB"});
db.transaction(function (tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS Locationlog (Coordinates TEXT, Location TEXT, Category TEXT, Address TEXT)');
});
db.transaction(function (tx){
tx.executeSql('INSERT INTO Locationlog (Coordinates, Location, Category, Address) VALUES (?,?,?,?)',[Latlongs,Location,Category,Address]);
});
});