1
我怎样才能SQLite中插入变量的值,我无法找到问题,我的代码,如果我使用INSERT语句如下这是工作和值插入,问题与SQLite中插入查询?(可变插入)
tx.executeSql('INSERT INTO Locationlog (Coordinates, Location, Category, Address) VALUES ("manju", "kishor", "ramesh", "ram")');
如果我尝试插入如下值没有被插入,
tx.executeSql('INSERT INTO Locationlog (Coordinates, Location, Category, Address) VALUES (?,?,?,?)',[Latlongs,Location,Category,Address]);
不用于查询像工作,
tx.executeSql('INSERT INTO Locationlog (Coordinates, Location, Category, Address) VALUES ('+Latlongs+', '+Location+', '+Category+', '+Address+')');
我对所有列使用TEXT作为数据类型,输入值大小在1-100之间。 TEXT数据类型的最大大小是多少?任何人都可以建议如何在插入查询中插入变量?
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]);
});
});