sqlite,javascript 输入空字符,避免被转成NULL

1. 问题

jssqlite数据库中写入空字符,被强制转换成了NULL

para1 = ""
para2 = ""
name= "admin"
tx.executeSql('UPDATE Users SET para1=?, para2=? WHERE name=?', [para1, para2, name]);

//para1和para2会写入NULL

2. 方法

{}代替""

para1 = {}
para2 = {}
name= "admin"
tx.executeSql('UPDATE Users SET para1=?, para2=? WHERE name=?', [para1, para2, name]);

//或
var value = {para1: {}, para2: {}, name: "admin"}

你可能感兴趣的:(Qt,sqlite,javascript)