SQLite查询已停止工作

时间:2013-10-22 09:28:09

标签: sqlite

* 突然间,查询开始显示没有这样的表,但直到昨天才正常工作。坚持这段代码。请帮忙*

点击

public void onClick(查看arg0){

            String stckCenterid=String.valueOf(headerDb.getStockCenterId(dat1));                    
            String stockItemId=String.valueOf(headerDb.getStockItemId(stckCenterid));

            System.out.println("StockCenterid, Stockitemid " + stckCenterid +"  "+ stockItemId);

        headerDb.getStockLedger(stckCenterid,stockItemId,from_date_format,to_date_format);




        }
        });

此库存中心ID正在按需要发送,但我将其传递给getstockitemid,但查询显示的不是此类表格,即下面的查询。我将这些中心ID和商品ID传递给另一个查询以获得结果

查询

public int getStockItemId(String stCenterId) {
        db = this.getReadableDatabase();
        Cursor c = db.rawQuery("SELECT STOCK_ITEM_ID from qt_um_stock_items_qty WHERE " +
                " STOCK_CENTRE_ID " + " = ? " , new String[] { stCenterId });
        c.moveToFirst();
        int index = c.getColumnIndex("STOCK_ITEM_ID");
        return c.getInt(index);

    }

logcat的

> 10-22 09:06:46.449: W/dalvikvm(1050): threadid=1: thread exiting with
> uncaught exception (group=0x40a71930) 10-22 09:06:46.509:
> E/AndroidRuntime(1050): FATAL EXCEPTION: main 10-22 09:06:46.509:
> E/AndroidRuntime(1050): android.database.sqlite.SQLiteException: no
> such table: qt_um_stock_items_qty (code 1): , while compiling: Select
> STOCK_ITEM_ID from qt_um_stock_items_qty WHERE STOCK_CENTER_ID=? 10-22
> 09:06:46.509: E/AndroidRuntime(1050):     at
> android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native
> Method) 10-22 09:06:46.509: E/AndroidRuntime(1050):   at
> android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:882)
> 10-22 09:06:46.509: E/AndroidRuntime(1050):   at
> android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:493)
> 10-22 09:06:46.509: E/AndroidRuntime(1050):   at
> android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
> 10-22 09:06:46.509: E/AndroidRuntime(1050):   at
> android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
> 10-22 09:06:46.509: E/AndroidRuntime(1050):   at
> android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37) 10-22
> 09:06:46.509: E/AndroidRuntime(1050):     at
> android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
> 10-22 09:06:46.509: E/AndroidRuntime(1050):   at
> android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1314)
> 10-22 09:06:46.509: E/AndroidRuntime(1050):   at
> android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1253)
> 10-22 09:06:46.509: E/AndroidRuntime(1050):   at
> com.manacle.umma.activity.HeaderDb.getItemId(HeaderDb.java:3864) 10-22
> 09:06:46.509: E/AndroidRuntime(1050):     at
> com.manacle.umma.activity.StockBalrep$4.onClick(StockBalrep.java:187)
> 10-22 09:06:46.509: E/AndroidRuntime(1050):   at
> android.view.View.performClick(View.java:4204) 10-22 09:06:46.509:
> E/AndroidRuntime(1050):   at
> android.view.View$PerformClick.run(View.java:17355) 10-22
> 09:06:46.509: E/AndroidRuntime(1050):     at
> android.os.Handler.handleCallback(Handler.java:725) 10-22
> 09:06:46.509: E/AndroidRuntime(1050):     at
> android.os.Handler.dispatchMessage(Handler.java:92) 10-22
> 09:06:46.509: E/AndroidRuntime(1050):     at
> android.os.Looper.loop(Looper.java:137) 10-22 09:06:46.509:
> E/AndroidRuntime(1050):   at
> android.app.ActivityThread.main(ActivityThread.java:5041) 10-22
> 09:06:46.509: E/AndroidRuntime(1050):     at
> java.lang.reflect.Method.invokeNative(Native Method) 10-22
> 09:06:46.509: E/AndroidRuntime(1050):     at
> java.lang.reflect.Method.invoke(Method.java:511) 10-22 09:06:46.509:
> E/AndroidRuntime(1050):   at
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
> 10-22 09:06:46.509: E/AndroidRuntime(1050):   at
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 10-22
> 09:06:46.509: E/AndroidRuntime(1050):     at
> dalvik.system.NativeStart.main(Native Method) 10-22 09:06:49.110:
> I/Process(1050): Sending signal. PID: 1050 SIG: 9 10-22 09:06:50.629:
> E/Trace(1330): error opening trace file: No such file or directory (2)
> 10-22 09:06:51.482: D/dalvikvm(1330): GC_FOR_ALLOC freed 130K, 10%
> free 2504K/2780K, paused 64ms, total 72ms 10-22 09:06:51.969:
> I/Choreographer(1330): Skipped 63 frames!  The application may be
> doing too much work on its main thread. 10-22 09:06:52.050:
> D/gralloc_goldfish(1330): Emulator without GPU emulation detected.
> 10-22 09:06:52.699: I/Choreographer(1330): Skipped 85 frames!  The
> application may be doing too much work on its main thread.

1 个答案:

答案 0 :(得分:0)

问题来自结构严密的代码:

总是在这里做一个String query =“SELECT ...”//查询 将查询记录到控制台中以检查语法。

在大写SELECT,INSERT,FROM,WHERE中编写sql命令在SQL关键字后使用新行

做一个:

SELECT * FROM qt_um_stock_items_qty;

确保表格存在。