なぜこのエラーが発生し続けるのかを理解しようとして、私はひどい時間を過ごしています。このフォーラムや他のフォーラムを検索しましたが、回答がないようですので、ここで質問します。
Titanium を使用して、Android 用の基本的な写真カタログ アプリを作成しようとしています。カタログ情報は sqlite データベースに保存されます。
データベースを作成できます。1 つのウィンドウでデータベースの情報にアクセスできます。次に、別のウィンドウに移動して、テーブルからさらに情報を取得しようとすると、エラーが表示されます。
キャッチされないエラー: そのようなテーブルはありません: 写真:, SELECT のコンパイル中........
以下のコードを参照してください。
これは、app.js から開く最初のウィンドウです。
テーブルはここで問題なく表示されます - エラーはありません
// create var for the currentWindow
var currentWin = Ti.UI.currentWindow;
// set the data from the database to the array
//function setData() {
// create table view
var tableview = Ti.UI.createTableView({
});
//var db = Ti.Database.open('catalogue');
//db.remove();
var db = Ti.Database.install('catalogue.sqlite','photos');
var rows = db.execute('SELECT * FROM photos GROUP BY title');
// create the array
var dataArray = [];
while(rows.isValidRow()) {
var title = rows.fieldByName('title');
var id = rows.fieldByName('id');
dataArray.push({title:title, id:id, url:'catalogue_detail.js'});
rows.next();
}
tableview.setData(dataArray);
// add the tableView to the current window
currentWin.add(tableview);
tableview.addEventListener('click', function(e){
if (e.rowData.url)
{
var win = Ti.UI.createWindow({
id:e.rowData.id,
title:e.rowData.title,
url:e.rowData.url
});
win.open();
}
});
// call the setData function to attach the database results to the array
//setData();
次に、上記からcatalogue_detail.jsを開くと、エラーが発生します
catalogue_detail.js
var win = Titanium.UI.currentWindow;
var id = win.id
var tableview = Titanium.UI.createTableView({
});
var db = Titanium.Database.open('catalogue.sqlite');//I have chanegd this to 'photos' and I get the same error
var sql = db.execute('SELECT title, location, photographer FROM photos where id="' + id + '"');
var title = sql.fieldByName('title');
var location = sql.fieldByName('location');
var photographer = sql.fieldByName('photographer');
// create the array
var dataArray = [];
while(sql.isValidRow()) {
var title = sql.fieldByName('title');
var location = sql.fieldByName('location');
var photographer = sql.fieldByName('photographer');
dataArray.push({title:title, location:location, photographer:photographer});
sql.next();
}
tableview.setData(dataArray);
win.add(tableview);
データベース内の「写真」というテーブルが 1 つのウィンドウで開くと、同じデータベースを開こうとするとエラーが発生しますか?
アプリをアンインストールし、データベースを再作成し、テーブルの名前を変更しましたが、それでも同じエラーが発生します...
私が見逃しているのは単純なことだと確信していますが、私は非常に混乱しています!
ご協力ありがとうございます。
JC