2015-01-14 44 views
1

我已經爲我的android項目使用sqlite創建了我的表。之前它工作得很好。最初,我創建了3個字段以確保連接能夠正常工作,並且它添加了所有我需要的其他字段,但是我收到了光標錯誤。在閱讀了類似的問題後,我認爲這將是onUpgrade的一個問題,所以我卸載了應用程序並重新安裝了,但現在它不斷崩潰,並且出現語法錯誤。android.database.sqlite.SQLiteException:

這裏是我的代碼

public void onCreate(SQLiteDatabase db){ 

     db.execSQL("CREATE TABLE " + DATABASE_TABLE_SITE_INFO + " (" 
       + ROW_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " 
       + SYSAID_ID + " TEXT, " 
       + SITE_ID + " TEXT, " 
       + LINK_ID + " TEXT, " 
       + CUSTOMER_NAME + " TEXT, " 
       + SITE_CONTACT + " TEXT, " 
       + TASK_TYPE + " TEXT, " 
       + ADDRESS + " TEXT, " 
       + REGION + " TEXT, " 
       + PHONE + " TEXT, " 
       + FAX + " TEXT, " 
       + MOBILE + " TEXT, " 
       + EMAIL + " TEXT, " 
       + LANDLORD_NAME + " TEXT, " 
       + RENT_STATUS + " TEXT, " 
       + LOCATION + " TEXT, " 
       + ENGINEER_NAME + " TEXT, " 
       + ENGINEER_SIGN + " BLOB, " 
       + POWER_STATUS + " TEXT, " 
       + VOLTAGE_MEASUREMENT + " TEXT, " 
       + AIRCON + " TEXT, " 
       + SERVER_ROOM_STATUS + " TEXT, " 
       + LOCATION_IDU + " TEXT, " 
       + EARTHING + " TEXT, " 
       + DISTANCE_IDU + " TEXT, " 
       + SECURITY_CABLES + " TEXT, " 
       + DUCTS + " TEXT, " 
       + UNIT_TYPE + " TEXT, " 
       + INST_TYPE + " TEXT, " 
       + HAVE_ISP + " TEXT, " 
       + RADIO + " TEXT, " 
       + ISP_TYPE + " TEXT, " 
       + ISP_NAME + " TEXT, " 
       + SNR_RX + " TEXT, " 
       + BS + " TEXT, " 
       + REMARKS + " TEXT);"); 

這是錯誤代碼我得到

01-14 10:22:28.429 24406-24406/com.example.sweetiean.stlfieldinstallation1 E/AndroidRuntime﹕ FATAL EXCEPTION: main 
Process: com.example.sweetiean.stlfieldinstallation1, PID: 24406 
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.sweetiean.stlfieldinstallation1/com.example.sweetiean.stlfieldinstallation1.MainActivity}: android.database.sqlite.SQLiteException: near "(": syntax error (code 1): , while compiling: CREATE TABLE site_info_table(_id INTEGER PRIMARY KEY AUTOINCREMENT, sysaid_id TEXT, site_id TEXT, link_id TEXT, customer_name TEXT, site_contact_name TEXT, task_type TEXT, address TEXT, region TEXT, phone TEXT, fax TEXT, mobile TEXT, email TEXT, landlord_name TEXT, rent_status TEXT, location TEXT, engineer_name TEXT, engineer_sign BLOB, power_status TEXT, voltage_measure TEXT, aircon TEXT, server_room_status TEXT, location_of_idu TEXT, earthing TEXT, distance_idu TEXT, security_of_cables TEXT, ducts TEXT, unit_to_be_installed TEXT, inst_type TEXT, isp TEXT, radio_type TEXT, isp_type TEXT, isp_name TEXT, snr(rx) TEXT, bs TEXT, remarks TEXT); 

回答

3

snr(rx)不是一個有效的列名,因爲括號。重命名爲例如snr_rx

+1

在「有效列名」 –

+3

之前添加「is not」,或者如果希望在表中創建列名爲「snr(rx)」,則使用[snr(rx)] TEXT而不是snr(rx) TEXT' –

+0

我沒有足夠的聲望點來提高你的答案,但我需要你知道它的工作。榮譽! –

相關問題