【发布时间】:2018-10-07 03:20:53
【问题描述】:
我实际上尝试使用 SQLite 制作移动应用程序。我只是尝试创建两个表:
constructor(private sqlite:SQLite,public modalCtrl: ModalController,public navCtrl: NavController, private navParam: NavParams, private databaseprovider: DatabaseProvider, private employeesProvider: EmployeeProvider) {
this.createDetabaseFile();
}
private createDetabaseFile() : void {
this.sqlite.create({
name: DATABASE_FILE_NAME,
location: 'default'
}).then((dbRes: SQLiteObject) => {
alert("bdd créée");
this.db = dbRes;
this.createTables();
})
}
private createTables() : void {
this.db.executeSql('CREATE table IF NOT EXISTS symbole(id INTEGER NOT NULL ,name TEXT)',{})
.then(() => {
alert("table symbole created");
this.db.executeSql('CREATE table IF NOT EXISTS representationPhoto(name VARCHAR(32))',{})
.then(() => {
alert("table representationPhoto created");
})
.catch(e => alert("erreur creation table"));
})
.catch(e => alert("erreur creation table"));
}
db.executeSql() 似乎不起作用,确实,alert("table symbole created"); 没有出现,但是 alert("bdd créée") 出现了,并且程序没有触发捕获。
你有什么想法吗?
ps:对不起我的英语不好
【问题讨论】:
-
您可以尝试将 dbRes 作为参数传递给 createTables() 方法并使用它来代替 this.db 吗?
标签: sqlite ionic-framework mobile