插入语句期间的字符串连接问题
string concatenation issue during insert statement
我有一个构造插入查询的方法,但由于字符串格式错误而崩溃。我缺少什么?
saveWorkDocket : function(onSuccessCallback, onErrorCallback, options) {
var db = Ti.Database.open('xyz');
db.execute("INSERT INTO tbl_temp (tableName, data, id, dateCreated) VALUES ('" + options.tableName + "','" + options.data + "','" + options.workdocketID + "','" + options.dateCreated +'");
db.close();
}
您缺少在查询末尾关闭 double " 并关闭函数括号,试试这个:
var db = Ti.Database.open('xyz');
db.execute("INSERT INTO tbl_temp (tableName, data, id, dateCreated) VALUES ('" + options.tableName + "','" + options.data + "','" + options.workdocketID + "','" + options.dateCreated +'")");
我有一个构造插入查询的方法,但由于字符串格式错误而崩溃。我缺少什么?
saveWorkDocket : function(onSuccessCallback, onErrorCallback, options) {
var db = Ti.Database.open('xyz');
db.execute("INSERT INTO tbl_temp (tableName, data, id, dateCreated) VALUES ('" + options.tableName + "','" + options.data + "','" + options.workdocketID + "','" + options.dateCreated +'");
db.close();
}
您缺少在查询末尾关闭 double " 并关闭函数括号,试试这个:
var db = Ti.Database.open('xyz');
db.execute("INSERT INTO tbl_temp (tableName, data, id, dateCreated) VALUES ('" + options.tableName + "','" + options.data + "','" + options.workdocketID + "','" + options.dateCreated +'")");