我正在编写一个应用程序,我需要存储用户生成的数据。这是代码:
<script type="text/javascript">
function saveData() {
var db;
var version = 1.0;
var dbName = "periodtwodb";
var dbDisplayName = "periodtwo_db";
var dbSize = 2 * 1024 * 1024;
try {
db = openDatabase(dbName, version, dbDisplayName, dbSize,
function(dbName) {
alert("database creation callback");
});
} catch (err) {
console.log(err);
}
dbName
.transaction(
function(sqlTransaction) {
sqlTransaction
.executeSql(
"CREATE TABLE IF NOT EXISTS notes(Date TEXT PRIMARY KEY bloodFlow INTEGER, p_start BOOLEAN, note TEXT, medicine TEXT, intercourse BOOLEAN, weight INTEGER, temparature INTEGER)",
[],
function(sqlTransaction,
sqlResultSet) {
sqlTransaction
.executeSql("INSERT INTO notes (Date, bloodFlow, p_start, note, medicine, intercourse, weight, temparature) VALUES ("+dte+", "+star+", "+checkone+", "+nte+", "+med+", "+checktwo+", "+wgt+", "+wgt1+")");
alert("table created successfully");
},
function(sqlTransaction,
sqlError) {
console.log(sqlError);
alert("Transaction error");
});
},
function() {
alert("SQL statements were executed successfully.");
});
}
</script>
错误是:Uncaught TypeError: undefined is not a function
对于线dbName.transaction(function(sqlTransaction) {
. 我该如何解决?数据库已成功创建,但未创建表。