我在鈦手機中使用sqlite。我沒有問題在另一張桌子上運行更新,在同一個數據庫中,所以我的連接似乎沒問題。然而,當我在表上運行插入時,我沒有得到任何插入的數據,也沒有引發錯誤/異常。所以我很困惑發生了什麼。這裏是我的表結構SQL插入沒有錯誤,但表沒有數據
CREATE TABLE events (
gCal_uid VARCHAR,
title VARCHAR,
content VARCHAR,
location VARCHAR,
startTime VARCHAR,
endTime VARCHAR,
published VARCHAR,
updated VARCHAR,
eventStatus VARCHAR
);
這裏是代碼。你可以看到下面的插入語句。在變量的輸出上,它們都有數據。可能我的語法錯了?
var db = Ti.Database.open('content');
Titanium.API.info(" number or results returned = " + cal.feed.entry.length);
var i;
for (i=0; i < cal.feed.entry.length; i++){
var e = cal.feed.entry[i];
var calUid = e.gCal$uid.value;
var title = e.title.$t;
var content = e.content.$t;
var location = e.gd$where.valueString;
var startTime = e.gd$when[0].startTime;
var endTime = e.gd$when[0].endTime;
var published = e.published.$t;
var updated = e.updated.$t;
var eventStatus = e.gd$eventStatus.value;
Titanium.API.info(calUid + title + content + location + startTime + endTime + published + updated + eventStatus);
var theData = db.execute('INSERT INTO events (gCal_uid, title, content, location, startTime, endTime, published, updated, eventStatus) VALUES("'+calUid+'","'+title+'", "'+content+'", "'+location+'", "'+startTime+'", "'+endTime+'", "'+published+'", "'+updated+'", "'+eventStatus+'")');
theData;
Ti.API.info("rows inserted" + i);
}
Ti.API.info("closed the db");
db.close();
請!!!!!準備SQL語句時逃脫你的價值觀! – Benoit 2011-02-07 17:20:57