郭宏志的android无线点餐系统的点菜功能怎么实现不了

pdz 发布于 2012/07/16 10:28
阅读 3K+
收藏 1

07-16 02:22:18.129: ERROR/AndroidRuntime(545): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.amaker.wlo/com.amaker.wlo.OrderActivity}: android.database.sqlite.SQLiteException: no such table: TableTbl: , while compiling: SELECT _id, num, description FROM TableTbl ORDER BY num DESC
07-16 02:22:18.129: ERROR/AndroidRuntime(545):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
07-16 02:22:18.129: ERROR/AndroidRuntime(545):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
07-16 02:22:18.129: ERROR/AndroidRuntime(545):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
07-16 02:22:18.129: ERROR/AndroidRuntime(545):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
07-16 02:22:18.129: ERROR/AndroidRuntime(545):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-16 02:22:18.129: ERROR/AndroidRuntime(545):     at android.os.Looper.loop(Looper.java:123)
07-16 02:22:18.129: ERROR/AndroidRuntime(545):     at android.app.ActivityThread.main(ActivityThread.java:4627)
07-16 02:22:18.129: ERROR/AndroidRuntime(545):     at java.lang.reflect.Method.invokeNative(Native Method)
07-16 02:22:18.129: ERROR/AndroidRuntime(545):     at java.lang.reflect.Method.invoke(Method.java:521)
07-16 02:22:18.129: ERROR/AndroidRuntime(545):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-16 02:22:18.129: ERROR/AndroidRuntime(545):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-16 02:22:18.129: ERROR/AndroidRuntime(545):     at dalvik.system.NativeStart.main(Native Method)
07-16 02:22:18.129: ERROR/AndroidRuntime(545): Caused by: android.database.sqlite.SQLiteException: no such table: TableTbl: , while compiling: SELECT _id, num, description FROM TableTbl ORDER BY num DESC
07-16 02:22:18.129: ERROR/AndroidRuntime(545):     at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
07-16 02:22:18.129: ERROR/AndroidRuntime(545):     at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:91)
07-16 02:22:18.129: ERROR/AndroidRuntime(545):     at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:64)
07-16 02:22:18.129: ERROR/AndroidRuntime(545):     at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:80)
07-16 02:22:18.129: ERROR/AndroidRuntime(545):     at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:46)
07-16 02:22:18.129: ERROR/AndroidRuntime(545):     at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42)
07-16 02:22:18.129: ERROR/AndroidRuntime(545):     at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1345)
07-16 02:22:18.129: ERROR/AndroidRuntime(545):     at android.database.sqlite.SQLiteQueryBuilder.query(SQLiteQueryBuilder.java:330)
07-16 02:22:18.129: ERROR/AndroidRuntime(545):     at android.database.sqlite.SQLiteQueryBuilder.query(SQLiteQueryBuilder.java:280)
07-16 02:22:18.129: ERROR/AndroidRuntime(545):     at com.amaker.provider.TableProvider.query(TableProvider.java:96)
07-16 02:22:18.129: ERROR/AndroidRuntime(545):     at android.content.ContentProvider$Transport.query(ContentProvider.java:163)
07-16 02:22:18.129: ERROR/AndroidRuntime(545):     at android.content.ContentResolver.query(ContentResolver.java:245)
07-16 02:22:18.129: ERROR/AndroidRuntime(545):     at android.app.Activity.managedQuery(Activity.java:1520)
07-16 02:22:18.129: ERROR/AndroidRuntime(545):     at com.amaker.wlo.OrderActivity.setTableAdapter(OrderActivity.java:120)
07-16 02:22:18.129: ERROR/AndroidRuntime(545):     at com.amaker.wlo.OrderActivity.onCreate(OrderActivity.java:71)
07-16 02:22:18.129: ERROR/AndroidRuntime(545):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-16 02:22:18.129: ERROR/AndroidRuntime(545):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
表我明明建好了,但还是显示出这个结果

public class DBHelper extends SQLiteOpenHelper{
    // 数据库名称常量
    private static final String DATABASE_NAME = "Wireless.db";
    // 数据库版本常量
    private static final int DATABASE_VERSION = 2;
    // 表名称常量
    public static final String TABLES_TABLE_NAME = "TableTbl";
    public static final String TABLES_TABLE_NAME2 = "MenuTbl";
    public String table="CREATE TABLE " + TABLES_TABLE_NAME + " ("
    + Tables._ID + " INTEGER PRIMARY KEY,"
    + Tables.NUM + " TEXT,"
    + Tables.DESCRIPTION + " TEXT"
    + ");";
 // 构造方法
 public DBHelper(Context context) {
  // 创建数据库
  super(context, DATABASE_NAME,null, DATABASE_VERSION);
 }

 // 创建时调用
 public void onCreate(SQLiteDatabase db) {
  //将注释去掉---Bylee
        db.execSQL(table);
       
        db.execSQL("CREATE TABLE " + TABLES_TABLE_NAME2 + " ("
                + Menus._ID + " INTEGER PRIMARY KEY,"
                + Menus.TYPE_ID + " INTEGER,"
                + Menus.NAME + " TEXT,"
                + Menus.PRICE + " INTEGER,"
                + Menus.PIC + " TEXT,"
                + Menus.REMARK + " TEXT"
                + ");");
 }

 // 版本更新时调用
 public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
  // 删除表
  db.execSQL("DROP TABLE IF EXISTS TableTbl");//将注释去掉---Bylee
  db.execSQL("DROP TABLE IF EXISTS MenuTbl");
        onCreate(db);
 }

}

加载中
0
红薯
红薯
android.database.sqlite.SQLiteException: no such table: TableTbl
p
pdz
怎么改?
0
迷途d书童
迷途d书童
com.amaker.provider.TableProvider.query(TableProvider.java:96)
这句有错。
0
侯林宏
侯林宏
 no such table: TableTbl: , while compiling: SELECT _id, num, description FROM TableTbl ORDER BY num DESC
这里错了。排序是不需要写desc的。默认是降序。
侯林宏
侯林宏
那报什么错呀。还是原来的错误吗?没有表,就是你写的代码问题了。你自己分析分析吧。这程序我又看不到。叫你调试不调试。不理了
p
pdz
回复 @侯林宏 : 表还是没有
侯林宏
侯林宏
这个错误明显就是表没有创建成功找不到该表。你把你自己写的这两行注释了。换上这行试试下。db.execSQL("create table tableTbl(_id integer primary key autoincrement,num integer not null,,description text not null)");
p
pdz
回复 @侯林宏 : 还是没用....你看看源代码吧
侯林宏
侯林宏
你数据库的字段的属性是小写还是大写的。java是区分大小写的。如果是大写的就改写全部是大写的。小写的就改写全部是小写的。我不知是不是这个。你试下。我叫你调试,你不调试怎么知道是什么问题呀?
下一页
0
侯林宏
侯林宏

很肯定就是sql出错了。你可以试着调试下。创建表的的时候可以全部都为空么?

0
迷途d书童
迷途d书童
在创建TableTbl表的语句里面加上if not exists TableTbl
0
Z
ZYud

很明显的错误

no such table: TableTbl

应该是创建的问题,大小写要一至.

0
spegar
spegar
基于android的无线点餐交流群:254188001 ,欢迎加入!
返回顶部
顶部