検索方法を実行すると、実行時エラーが発生しました
error:- 05-04 14:04:00.227: E/AndroidRuntime(4559): Caused by:
android.database.sqlite.SQLiteException: no such column: ww (code 1): ,
while compiling: SELECT DISTINCT faculty, deparment, name, officeNumber,
phoneNumber, emailAddress, officeHour FROM teacherInfo WHERE name=ww
ユーザーが名前を入力したときに教師名を検索し、名前、学部、部門、電話、電子メール、オフィス番号、オフィスアワーなど、この教師に関するすべての情報を表示する必要があります
これは DBAdapter.java の getRecord メソッドです
public Cursor getRecord(String n1) throws SQLException
{
Cursor mCursor =db.query(true,tableName , new String[] {facultyc,
deparmentc, namec, officeNumberc,Phonec ,emailAddressc,officeHourc},namec + "=" + n1, null, null, null, null, null);
if (mCursor != null) {
mCursor.moveToFirst();
}
return mCursor;
}
および Information.java のこの検索メソッド
public void search(){
db.open();
Cursor c = db.getRecord(n);
if (c.moveToFirst()){
t1.setText(c.getString(0));
t2.setText(c.getString(1));
t3.setText(c.getString(2));
t4.setText(c.getString(3));
t5.setText(c.getString(4));
t6.setText(c.getString(5));
t7.setText(c.getString(6));
}
else
Toast.makeText(this, "this Dr not found", Toast.LENGTH_LONG).show();
db.close();
}
DBAdapter.java のこの Oncreate メソッド
public void onCreate(SQLiteDatabase db)
DATABASE_CREATE =
"create table if not exists teacherInfo (teacherNumber INTEGER primary key autoincrement,"
+ "name TEXT not null, faculty TEXT,deparment TEXT,officeNumber INTEGER,officeHour TEXT, emailAddress TEXT,phoneNumber TEXT, location INTEGER );";
{
try {
db.execSQL(DATABASE_CREATE);
} catch (SQLException e) {
e.printStackTrace();
}
}