我想在我的應用程序中添加sqlite我已經創建了數據庫和表,但是SELECT和INSERT查詢不起作用我不知道爲什麼? 在這裏,我已經加了我的代碼:Android SQLITE查詢異常錯誤?
static Cursor c;
SQLiteDatabase db;
db=openOrCreateDatabase("weatherregisterDB", Context.MODE_PRIVATE, null);
db.execSQL("CREATE TABLE IF NOT EXISTS weatherRegister(id INTEGER PRIMARY KEY AUTOINCREMENT,name VARCHAR,username VARCHAR,password VARCHAR,confirmpassword VARCHAR);");
register.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
db.execSQL("INSERT INTO weatherRegister(id,name,username,password,confirmpassword) VALUES('',sample,sample,sample,sample);");
c=db.rawQuery("SELECT username FROM weatherRegister WHERE username=sample", null);
我的錯誤是:
android.database.sqlite.SQLiteException: no such column: sample (code 1): , while compiling: INSERT INTO weatherRegister(id,name,username,password,confirmpassword) VALUES('',sample,sample,sample,sample);
也顯示你的logcat – 2015-03-02 06:03:58
什麼錯誤你得到pls分享到 – eLemEnt 2015-03-02 06:04:34
CREATE TABLE查詢是否工作?可能不是因爲*列名和類型之間缺少空格*請分享崩潰日誌 – 2015-03-02 06:04:52