android 提示这个错误 Caused by:android.database.sqlite.SQLiteException:no such column:xuehao:这句话产生的 \x05Cursor cur=database.query(tablename,new String[]{XUEHAO,xingming},null,null,null,null,null);这个所有代码 public class Shu

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/23 19:10:48
android提示这个错误Causedby:android.database.sqlite.SQLiteException:nosuchcolumn:xuehao:这句话产生的\x05Cursorcu

android 提示这个错误 Caused by:android.database.sqlite.SQLiteException:no such column:xuehao:这句话产生的 \x05Cursor cur=database.query(tablename,new String[]{XUEHAO,xingming},null,null,null,null,null);这个所有代码 public class Shu
android 提示这个错误 Caused by:android.database.sqlite.SQLiteException:no such column:xuehao:
这句话产生的 \x05Cursor cur=database.query(tablename,new String[]{XUEHAO,xingming},null,null,null,null,null);
这个所有代码 public class Shu extends Activity {
\x05private static int miCount = 0;
\x05private ListView list;
\x05private SQLiteDatabase database;
\x05private static String databasename="xuesheng.db";
\x05private static String tablename="table1";
\x05private static String XUEHAO="xuehao";
\x05private static String xingming="xingming";
\x05private static String createtable="CREATE TABLE "+tablename+"("+XUEHAO+" INTEGER PRIMARY KEY,"+xingming+"TEXT)";
private Button add;
/** Called when the activity is first created.*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
list=(ListView)findViewById(R.id.listView1);
add=(Button)findViewById(R.id.button1);
database=this.openOrCreateDatabase(databasename,MODE_PRIVATE,null);
try
{
/* 在数据库mSQLiteDatabase中创建一个表 */
\x05database.execSQL(createtable);
}
catch (Exception e)
{
\x05 audata();
}
add.setOnClickListener(new View.OnClickListener() {
\x05\x05
\x05\x05@Override
\x05\x05public void onClick(View v) {
\x05\x05\x05// TODO Auto-generated method stub
\x05\x05\x05 AddData();
\x05\x05}
\x05}) ;
}
public void AddData()
{
ContentValues cv = new ContentValues();
cv.put(XUEHAO,"111");
cv.put(xingming,"sdaf");
/* 插入数据 */
database.insert(tablename,null,cv);
miCount++;
audata();
}
private void audata(){
\x05
\x05Cursor cur=database.query(tablename,new String[]{XUEHAO,xingming},null,null,null,null,null);
\x05
\x05 miCount = cur.getCount();
if (cur = null && cur.getCount() >= 0)
{
\x05ListAdapter adapter=new SimpleCursorAdapter(this,
\x05\x05\x05android.R.layout.simple_list_item_2,
\x05\x05\x05cur,
\x05\x05\x05new String[]{XUEHAO,xingming},
\x05\x05\x05new int[]{android.R.id.text1,android.R.id.text2});
\x05
\x05list.setAdapter(adapter);
}
}}

android 提示这个错误 Caused by:android.database.sqlite.SQLiteException:no such column:xuehao:这句话产生的 \x05Cursor cur=database.query(tablename,new String[]{XUEHAO,xingming},null,null,null,null,null);这个所有代码 public class Shu
Caused by:android.database.sqlite.SQLiteException:no such column:Li:SQL代码没写对,用字符串查询的时候要加单引号如 name=’Li‘,注意单引号