我有连接错误列:android.database.sqlite.SQLiteException:表aerzte没有名为_vorname安卓:表中有没有名为“列名”
列,但我的表有列_vorname。我找不到错误,请帮助我。 下面是代码:
private static final int DATABASE_VERSION = 1;
private static final String DATABASE_NAME = "data.db";
private static final String TABLE_Aerzte = "aerzte";
private static final String COLUMN_ID = "_id";
private static final String COLUMN_Name = "_name";
private static final String COLUMN_Passwort = "_passwort";
private static final String COLUMN_Vorname = "_vorname";
//second table
private static final String TABLE_Patienten = "patienten";
private static final String COLUMN_patID = "_id";
private static final String COLUMN_patName = "_name";
private static final String COLUMN_patVorname = "_vorname";
private static final String COLUMN_patSVNR = "_svnr";
//third table
private static final String TABLE_Werte = "werte";
private static final String COLUMN_wertID = "_id";
private static final String COLUMN_wertpatName = "_name"; //foreign key -> patient (1:n) beziehung
private static final String COLUMN_wertDatzeit = "_datzeit";
private static final String COLUMN_wertTemperatur = "_temperatur";
private static final String COLUMN_wertMessort = "_messort";
public MyDBHandler(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
super(context, DATABASE_NAME, factory, DATABASE_VERSION);
}
//create tables:
@Override
public void onCreate(SQLiteDatabase db) {
//tabelle arzt
String query = "CREATE TABLE "+TABLE_Aerzte+"("+COLUMN_ID+" INTEGER PRIMARY KEY AUTOINCREMENT, "+COLUMN_Passwort+" TEXT, "+COLUMN_Name+ " TEXT, " +COLUMN_Vorname+ "TEXT " + ");";
db.execSQL(query);
//tabelle patient
String query2 = "CREATE TABLE "+TABLE_Patienten+"("+COLUMN_patID+" INTEGER PRIMARY KEY AUTOINCREMENT, "+COLUMN_patName+" TEXT,"+COLUMN_patVorname+" TEXT, "+COLUMN_patSVNR+" LONG" + ");";
db.execSQL(query2);
//tabelle wert
String query3 = "CREATE TABLE "+TABLE_Werte+"("+COLUMN_wertID+" INTEGER PRIMARY KEY AUTOINCREMENT, "+COLUMN_wertMessort+" TEXT, "+COLUMN_wertTemperatur+ " INTEGER, "+COLUMN_wertDatzeit+" DATETIME, "+COLUMN_wertpatName+" TEXT, FOREIGN KEY" + ");";
db.execSQL(query3);
}
//insert
public void registerPhysician(Fieberwerte fieberwerte) { // public void registerPhysician(etname, etpass, etvorname)
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
//values.put(COLUMN_ID, 1);
values.put(COLUMN_Passwort, fieberwerte.getPasswort());
values.put(COLUMN_Name, fieberwerte.getName());
values.put(COLUMN_Vorname, fieberwerte.getVorname());
//db.insert(TABLE_Aerzte, null, values);
db.insertWithOnConflict(TABLE_Aerzte, null, values, SQLiteDatabase.CONFLICT_REPLACE);
//db.close();
}
我希望你们能帮助我解决这个错误。我检查了代码几次,但我没有找到:-(
题外话:*这个问题是由一个问题引起的,不能再被复制或**一个简单的印刷错误。*** – Selvin