我确信我做错了什么,但在投入大量时间后未能确定是什么。简而言之,错误是某个列不存在,但我之前创建了它:
static final String itemTable="ITEMS";
static final String colItemID="ItemID";
static final String colItemName="ItemName";
static final String colQuantity="ItemQuantity";
static final String colPrice="ItemPrice";
static final String colCategory="ItemCategory";
static final String colAisle="ItemAisle";
static final String colCreator="ItemCreator";
static final String colActMemID="ItemActivityMemberID";
static final String colDate="ItemDate";
static final String colHistory="ItemHistory";
static final String colPicture="ItemPicture";
创建表命令:
try {
db.execSQL("CREATE TABLE " + itemTable + " " + "(" + colItemID +
" INTEGER PRIMARY KEY AUTOINCREMENT, " + colItemName + " TEXT, " +
colQuantity + " Integer, " + colPrice + "REAL, " + colCategory + " TEXT, "
+ colAisle + " TEXT, " + colCreator + " TEXT, " + colActMemID + " TEXT, " +
colDate + " TEXT, " + colHistory + " TEXT, " + colPicture + " TEXT)");
} catch (SQLException e) {
System.out.println(e);
}
然后,当我尝试创建视图时:
try {
db.execSQL("CREATE VIEW "+viewList+
" AS SELECT "+itemTable+"."+colItemID+" AS _id,"+
" "+itemTable+"."+colItemName+","+
" "+itemTable+"."+colPrice+","+
" "+itemTable+"."+colQuantity+","+
" "+membersTable+"."+colMemName+""+
" FROM "+itemTable+" JOIN "+membersTable+
" ON "+itemTable+"."+colActMemID+" ="+membersTable+"."+colMemID
);
} catch (SQLException e) {
// TODO Auto-generated catch block
System.out.println(e);
}
他抱怨了一个特定的专栏:
07-22 10:33:26.548: I/System.out(1753): back from db construct
07-22 10:33:26.628: E/SQLiteLog(1753): (1) no such column: ITEMS.ItemPrice
07-22 10:33:26.638: D/AndroidRuntime(1753): Shutting down VM
07-22 10:33:26.638: W/dalvikvm(1753): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
07-22 10:33:26.688: E/AndroidRuntime(1753): FATAL EXCEPTION: main
07-22 10:33:26.688: E/AndroidRuntime(1753): android.database.sqlite.SQLiteException: no such
column: ITEMS.ItemPrice (code 1): , while compiling: CREATE VIEW ViewList AS SELECT ITEMS.ItemID
AS _id, ITEMS.ItemName, ITEMS.ItemPrice, ITEMS.ItemQuantity, MEMBERS.MemberName FROM ITEMS JOIN
MEMBERS ON ITEMS.ItemActivityMemberID =MEMBERS.MemberID
07-22 10:33:26.688: E/AndroidRuntime(1753): at
android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
07-22 10:33:26.688: E/AndroidRuntime(1753): at
android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:882)
07-22 10:33:26.688: E/AndroidRuntime(1753): at
android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:493)
07-22 10:33:26.688: E/AndroidRuntime(1753): at android.database.sqlite.SQLiteSession.prepare
(SQLiteSession.java:588)
我查看了尽可能多的答案,但没有找到任何线索,我们将非常感谢您的帮助!
肿瘤坏死因子,
加尔