得到“(1)没有这样的列:_id10”错误

时间:2013-12-31 23:03:11

标签: java android sqlite

我试图检索sqlite数据库中微粒行的数据。并尝试将其显示在EditText上,但我收到此错误,请帮助我解决错误!

提前致谢:)

这里是显示错误的logcat数据

    12-31 22:28:17.731: E/2.4(12285): 111111
12-31 22:28:17.741: E/2.5(12285): 111111
12-31 22:28:17.771: E/SQLiteLog(12285): (1) no such column: _id10
12-31 22:28:17.791: D/AndroidRuntime(12285): Shutting down VM

这里是代码:(函数getName,用于检索第1列的数据)[在log.e之后得到错误(&#34; 2.5&#34; ....)] < / p>

 public String getName(long l) {
        // TODO Auto-generated method stub
        Log.e("2.4","111111");
        String[] column = new String[]{KEY_ROWID, KEY_NAME, KEY_HOTNESS };
        Log.e("2.5","111111");
        Cursor c = ourDatabase.query(DATABASE_TABLE, column, KEY_ROWID + "" + l, null, null, null, null);
        Log.e("2.6","111111");
        if(c != null)
        { 
            Log.e("2.7","111111");
            c.moveToFirst();
            Log.e("2.8","111111");
            String name = c.getString(1);
            Log.e("2.9","111111");
            return name;

        }
        return null;
    }
public String getHotness(long l)
{
    Log.e("3.1","111111");
    // TODO Auto-generated method stub
    String[] column = new String[]{KEY_ROWID, KEY_NAME, KEY_HOTNESS };
    Log.e("3.2","111111");
    Cursor c = ourDatabase.query(DATABASE_TABLE, column, KEY_ROWID + "" + l, null, null, null, null);
    Log.e("3.3","111111");
    if(c != null)

    {
        Log.e("3.4","111111");
        c.moveToFirst();
        Log.e("3.5","111111");
        String hotness = c.getString(2);
        Log.e("3.6","111111");
        return hotness;

    }
    return null;
}

并且是调用此函数的活动的代码

case R.id.bgetInfo:
        String s = sqlRow.getText().toString();
        long l = Long.parseLong(s);

        HotOrNot hon = new HotOrNot(this);
        hon.open();
        String returnedName = hon.getName(l);
        String returnedHotness = hon.getHotness(l);
        hon.close();    
        Log.e("1.2","111111");
        sqlName.setText(returnedName);
        Log.e("1.3","111111");
        sqlHotness.setText(returnedHotness);
        Log.e("1.4","111111");
        break;

1 个答案:

答案 0 :(得分:0)

我认为你错过了一个等号:

Cursor c = ourDatabase.query(DATABASE_TABLE, column, KEY_ROWID + "" + l, null, null, null, null); 

更改为:

Cursor c = ourDatabase.query(DATABASE_TABLE, column, KEY_ROWID + " = " + l, null, null, null, null);