public void onCreate(SQLiteDatabase arg0) { //数据库第一次被创建的时候调用
arg0.execSQL("CREATE TABLE kebiao( kebiaoid int ,name vachar(40),teacher vachar(10),place vachar(10),week vachar(20))");
for(int i=1;i<=35;i++)
arg0.execSQL("insert into kebiao(kebiaoid)values(?)",new Object[]{i});
}
public void update(SQLservice0 kebiao){
SQLiteDatabase arg0=sqlservice.getWritableDatabase();
arg0.execSQL("update kebiao set name=?,teacher=?,place=?,week=? where kebiaoid=?",
new Object [] {kebiao.getName(),kebiao.getTeacher(),kebiao.getPlace(),kebiao.getWeek(),kebiao.getId()});
}public SQLservice0(Integer id, String name, String teacher, String place,
String week) {
super();
this.id = id;
this.name = name;
this.teacher = teacher;
this.place = place;
this.week = week;
}
SQLservice1 sqlservice1=new SQLservice1(getBaseContext());
SQLservice0 kebiao=new SQLservice0(chuanzhi,edittext1.getText().toString(),edittext2.getText().toString(),edittext3.getText().toString(),edittext4.getText().toString());
sqlservice1.update(kebiao);我在创建数据库的时候明明以经写了kebiaoid这一列
可还是出错
no such column:kebiaoid
求解决
arg0.execSQL("CREATE TABLE kebiao( kebiaoid int ,name vachar(40),teacher vachar(10),place vachar(10),week vachar(20))");
for(int i=1;i<=35;i++)
arg0.execSQL("insert into kebiao(kebiaoid)values(?)",new Object[]{i});
}
public void update(SQLservice0 kebiao){
SQLiteDatabase arg0=sqlservice.getWritableDatabase();
arg0.execSQL("update kebiao set name=?,teacher=?,place=?,week=? where kebiaoid=?",
new Object [] {kebiao.getName(),kebiao.getTeacher(),kebiao.getPlace(),kebiao.getWeek(),kebiao.getId()});
}public SQLservice0(Integer id, String name, String teacher, String place,
String week) {
super();
this.id = id;
this.name = name;
this.teacher = teacher;
this.place = place;
this.week = week;
}
SQLservice1 sqlservice1=new SQLservice1(getBaseContext());
SQLservice0 kebiao=new SQLservice0(chuanzhi,edittext1.getText().toString(),edittext2.getText().toString(),edittext3.getText().toString(),edittext4.getText().toString());
sqlservice1.update(kebiao);我在创建数据库的时候明明以经写了kebiaoid这一列
可还是出错
no such column:kebiaoid
求解决
super(context,"t3g_db",null,1);
}
@Override
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
String str="create table airport(_id integer primary key autoincrement," +
" airport_city text, airport_name text,airport_code text)";
db.execSQL(str);
TextUtils.isEmpty(str);
Log.i("DB_Log","create table airport!");
} @Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// TODO Auto-generated method stub
}
public Cursor select(){
SQLiteDatabase db=this.getReadableDatabase();
Cursor cursor=db.query("airport", null, null, null, null, null, null);
return cursor;
}
public void insert(Airport airport){
SQLiteDatabase db=this.getWritableDatabase();
ContentValues cv=new ContentValues();
cv.put("_id", airport.getId());
cv.put("airport_city", airport.getCity());
cv.put("airport_name", airport.getName());
cv.put("airport_code", airport.getCode());
db.insert("airport", null, cv);
Log.i("DB_Log","insert data ok!");
}
public void delete(int id){
SQLiteDatabase db=this.getWritableDatabase();
db.delete("airport", "id = ?", new String[]{id+""});
Log.i("DB_Log", "delete one row OK!");
}
public void deleteAll(){
SQLiteDatabase db=this.getWritableDatabase();
db.delete("airport", null, null);
Log.i("DC_Log", "delete all data ok!");
}}