SQLiteException:没有这样的列:date(代码1):,同时编译:SELECT _id,name,date FROM member

时间:2015-03-15 06:15:19

标签: java android sqlite

我正在使用数据库,而我正在使用以下数据类

datahelper.java

private static final String CREATE_TABLE = "create table "
        + TABLE_MEMBER + "(" + MEMBER_ID
        + " INTEGER PRIMARY KEY AUTOINCREMENT, "
        + MEMBER_NAME + " TEXT NOT NULL,"
        + MEMBER_DATE + " TEXT NOT NULL);";

并将错误代码指向这两个java文件

SQLController.java

 public Cursor readData() {
        String[] allColumns = new String[] { DBhelper.MEMBER_ID,DBhelper.MEMBER_NAME,DBhelper.MEMBER_DATE};
        Cursor c = database.query(DBhelper.TABLE_MEMBER, allColumns,null, null, null, null, null);
        if (c != null) {
        c.moveToFirst();
       }
        return c;
    }

Mainactivity.java

     protected void onCreate(Bundle savedInstanceState) {

            super.onCreate(savedInstanceState);


  setContentView(R.layout.activity_main);
        dbcon = new SQLController(this);
        dbcon.open();
        addmem_bt = (Button) findViewById(R.id.addmem_bt_id);
        lv = (ListView) findViewById(R.id.memberList_id);

        addmem_bt.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent add_mem = new Intent(MainActivity.this, Add_member.class);
                startActivity(add_mem);
            }
        });

        // Attach The Data From DataBase Into ListView Using Crusor Adapter
        Cursor cursor = dbcon.readData();
        String[] from = new String[] { DBhelper.MEMBER_ID, DBhelper.MEMBER_NAME, DBhelper.MEMBER_DATE };
        int[] to = new int[] { R.id.member_id, R.id.member_name, R.id.member_date};

你所有的帮助

1 个答案:

答案 0 :(得分:1)

date是sqlite中的一个函数,我怀疑你不能用作列名或别名