编译我的查询时没有这样的列错误(代码 1)
no such column error (code 1) while compiling my query
我的公告中有这些专栏 table:announceno(autoincrement)、announceby(text)、announcetitle(text)、announcecontent(text)。
我的activity查看listview上的内容
通过从微调器中选择标题。所以我有这个查询,我需要从微调器中获取标题并在它等于标题时加载查询。 "NEW TITLE"是spinner的内容。
我有这个错误(更新):
android.database.sqlite.SQLiteException: no such column: announcetitle (code 1): , while compiling: SELECT * FROM tablemessage where announcetitle =?
我的查询(更新):
public Cursor announcements (String title){
SQLiteDatabase db = DBHelper.getWritableDatabase();
String selectQuery = "SELECT * FROM " + TABLE_MESSAGE +" where " +
KEY_ANNOUNCETITLE + " = ?";
Cursor data = db.rawQuery(selectQuery , new String[]{title});
return data;
}
我的列表视图(更新):
public void myMethod() {
if(spnr1.getSelectedItem().toString() == "--SELECT TITLE--"){
}else{
ArrayList<String> theList = new ArrayList<>();
String a = et16.getText().toString();
String h = spnr1.getSelectedItem().toString();
Cursor data = db.announcements(h);
if (data.moveToFirst()) {
do {
theList.add(data.getString(3));
ListAdapter listAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, theList);
lv.setAdapter(listAdapter);
} while (data.moveToNext());
}}
}
谢谢。结果我的 TABLE 应该是公告 table 而不是消息 table。这就是为什么没有这样的专栏。
我的公告中有这些专栏 table:announceno(autoincrement)、announceby(text)、announcetitle(text)、announcecontent(text)。
我的activity查看listview上的内容 通过从微调器中选择标题。所以我有这个查询,我需要从微调器中获取标题并在它等于标题时加载查询。 "NEW TITLE"是spinner的内容。
我有这个错误(更新):
android.database.sqlite.SQLiteException: no such column: announcetitle (code 1): , while compiling: SELECT * FROM tablemessage where announcetitle =?
我的查询(更新):
public Cursor announcements (String title){
SQLiteDatabase db = DBHelper.getWritableDatabase();
String selectQuery = "SELECT * FROM " + TABLE_MESSAGE +" where " +
KEY_ANNOUNCETITLE + " = ?";
Cursor data = db.rawQuery(selectQuery , new String[]{title});
return data;
}
我的列表视图(更新):
public void myMethod() {
if(spnr1.getSelectedItem().toString() == "--SELECT TITLE--"){
}else{
ArrayList<String> theList = new ArrayList<>();
String a = et16.getText().toString();
String h = spnr1.getSelectedItem().toString();
Cursor data = db.announcements(h);
if (data.moveToFirst()) {
do {
theList.add(data.getString(3));
ListAdapter listAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, theList);
lv.setAdapter(listAdapter);
} while (data.moveToNext());
}}
}
谢谢。结果我的 TABLE 应该是公告 table 而不是消息 table。这就是为什么没有这样的专栏。