我在這裏搜索了太多,但無法解決錯誤!列未找到 - Sqlite Android
我有marjorly 2班
public class DatabaseOperation extends SQLiteOpenHelper{
private static final int DATABASE_VERSION = 2;
public String QUERY = "CREATE TABLE " + TableData.TableInfo.TABLE_NAME +"("+ TableData.TableInfo.USER_NAME+"TEXT,"+
TableData.TableInfo.USER_EMAIL+"TEXT,"+ TableData.TableInfo.USER_NUMBER+"TEXT);";
public DatabaseOperation(Context context){
super(context, TableData.TableInfo.DATABASES_NAME,null,DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db){
db.execSQL(QUERY);
}
@Override
public void onUpgrade(SQLiteDatabase db,int oldVersion,int newVersion){
}
public void putInfo(DatabaseOperation dop,String name,String email,String pass,String no){
SQLiteDatabase sq = dop.getWritableDatabase();
ContentValues cv = new ContentValues();
cv.put(TableData.TableInfo.USER_NAME,name);
cv.put(TableData.TableInfo.USER_EMAIL,email);
cv.put(TableData.TableInfo.USER_NUMBER,no);
// cv.put(TableData.TableInfo.USER_PASS,pass);
cv.put(TableData.TableInfo.USER_STATE,"Available");
long k = sq.insert(TableData.TableInfo.TABLE_NAME,null,cv);
}
public boolean seacrhEmail(DatabaseOperation db,String email){
return true;
}
}
和
public class TableData {
public static abstract class TableInfo implements BaseColumns{
public static final String USER_NAME = "user_name";
public static final String USER_EMAIL = "user_eMail";
// public static final String USER_PASS = "user_pass";
public static final String USER_NUMBER = "user_phNumber";
public static final String DATABASES_NAME = "user_info";
public static final String TABLE_NAME = "taxi_registration";
public static final String USER_STATE = "taxi_state";
}
}
錯誤當我運行INSERT語句
06-03 21:57:26.459 3700-3700/com.example.jawad.testapplication E/SQLiteLog﹕ (1) table taxi_registration has no column named user_name
06-03 21:57:26.475 3700-3700/com.example.jawad.testapplication E/SQLiteDatabase﹕ Error inserting user_name=bb [email protected] taxi_state=Available user_phNumber=666
android.database.sqlite.SQLiteException: table taxi_registration has no column named user_name (code 1): , while compiling: INSERT INTO taxi_registration(user_name,user_eMail,taxi_state,user_phNumber) VALUES (?,?,?,?)
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:893)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:504)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1492)
at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1364)
at com.example.jawad.testapplication.d.a(Unknown Source)
at com.example.jawad.testapplication.r.onClick(Unknown Source)
at android.view.View.performClick(View.java:4463)
at android.view.View$PerformClick.run(View.java:18770)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5292)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
at dalvik.system.NativeStart.main(Native Method)
我跟着this tutorial ...我不知道我錯過了什麼......
PS:我對android有點新。
看起來你錯過了'TableData.TableInfo.USER_NAME +「文字,''之間的空格。 嘗試更改此格式的所有內容。 'TableData.TableInfo.USER_NAME +「TEXT,」//在TEXT之前加了一個空格' – siriscac
我很驚訝。表格是如何成功創建的? –
仍然我得到相同的錯誤... – Junaid