在cordova应用程序中的creatinf表时出错 [英] Error while creatinf table in cordova application
本文介绍了在cordova应用程序中的creatinf表时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的是使用sql lite作为数据库的aapche cordova应用程序项目
但是我在创建表时得到的错误如下:
Hi ,
I am using aapche cordova application project that uses sql lite as database
But The error which I am getting at the time of creating table is as belows
index.js:11 Uncaught TypeError: Cannot read property 'transaction' of undefined
我的尝试:
What I have tried:
var myDB;
//Open Database Connection
document.addEventListener("deviceready",onDeviceReady,false);
function onDeviceReady(){
myDB = window.sqlitePlugin.openDatabase({name: "mySQLite.db"});
}
//Create new table
$("#createTable").click(function(){
myDB.transaction(function(transaction) {
transaction.executeSql('CREATE TABLE IF NOT EXISTS phonegap_pro (id integer primary key, title text, desc text)', [],
function(tx, result) {
alert("Table created successfully");
},
function(error) {
alert("Error occurred while creating the table.");
});
});
});
推荐答案
( #createTable)。click( function (){
myDB.transaction( function (transaction){
transaction.executeSql(' CREATE TABLE IF NOT NOT EXISTS phonegap_pro(id integer primary key,title text,desc text)',[],
function (tx,result){
alert( 表创建成功);
},
function (错误){
alert( 创建表时出错。);
});
});
});
("#createTable").click(function(){ myDB.transaction(function(transaction) { transaction.executeSql('CREATE TABLE IF NOT EXISTS phonegap_pro (id integer primary key, title text, desc text)', [], function(tx, result) { alert("Table created successfully"); }, function(error) { alert("Error occurred while creating the table."); }); }); });
这篇关于在cordova应用程序中的creatinf表时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文