我在钛手机中使用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