0
"picture"という名前のデータベースを作成し、そこに値を保存するプログラムを作成しました。しかし、それは動作しません、彼はデータベースにエントリを保存します。 Google Chromeブラウザのコンソールにエラーが表示されません。アイデアはありますか?私のWebSQLスクリプトはデータベースにエントリを保存しません
var db = openDatabase("mskindb", '1.0', 'mskindb', 2 * 1024 * 1024);
var textMessage = "";
function initDatabase() {
db.transaction(function (tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS picture (id INTEGER PRIMARY KEY AUTOINCREMENT, docid0 TEXT, docid1 TEXT, doctype TEXT, data TEXT, date TEXT' +
'creation_date TEXT, delete_date TEXT, transmit_date TEXT)');
alert("initDatabase");
});
}
function dropTables() {
db.transaction(function (tx) {
tx.executeSql('DROP TABLE patient');
tx.executeSql('DROP TABLE picture');
tx.executeSql('DROP TABLE senderMessage');
tx.executeSql('DROP TABLE receiverMessage');
initDatabase();
alert("dropTables");
});
}
function dropPicture() {
db.transaction(function (tx) {
tx.executeSql('DROP TABLE picture');
initDatabase();
});
}
function addPatient(patient) {
db.transaction(function (tx) {
tx.executeSql('INSERT INTO patient (lastname, firstname) VALUES (?, ?)', [patient.lastName, patient.firstName]);
});
}
function addPicture() {
//textMessage = document.getElementById("patientMessage").value;
db.transaction(function (tx) {
tx.executeSql('INSERT INTO picture (docid0, ' +
'docid1, doctype, data, date, creation_date, transmit_date, delete_date) VALUES (?, ?, ?, ?, ?, ?, ?, ?)',
["0", "0", "mSkinPicture", JSON.stringify(actualPhoto), new Date(), "0", "0", "0"]);
alert("addPicture() ausgeführt");
alert(JSON.stringify(actualPhoto))
});
}
function displayAllPictures() {
alert("1");
var psrDisplayArea = document.getElementById("psrDisplayArea");
db.transaction(function (tx) {
alert("2");
tx.executeSql('SELECT * FROM picture', [], function (tx, results) {
alert("3");
alert(results.rows.length);
for (var i = 0; i < results.rows.length; i++) {
alert("4");
alert(JSON.parse(results.rows.item(i).data));
}
}, null);
});
}
//
actualPhoto = new photoData("HelloWorld");
function photoData(path) {
this.path = path;
}
//
initDatabase();
addPicture();
displayAllPictures();
ありがとうございました!私のエラー: "initDatabase()"の "date"の後に "、"を設定しない –