我已经使用sqlite为我的android项目创建了我的表。它之前工作得很好。最初,我创建了3个字段以确保连接可以正常工作,并且确实如此,我添加了我需要的所有其他字段但是我收到了光标错误。在这里阅读类似的问题之后,我认为这将是onUpgrade的一个问题,所以我卸载了应用程序并重新安装,但现在它一直崩溃,我收到语法错误。
这是我的代码
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);
答案 0 :(得分:3)
snr(rx)
不是有效的列名。将其重命名为例如snr_rx
。