伙计们,请你帮我解决这个问题。花了很多时间后我找不到错误。
这是我的代码
public static final String DATABASENAME = "IdeaCellularDatabase";
// Table Name
public static final String AUDIT_TABLE = "audit_table";
public static final String IMAGE_TABLE = "images_table";
// Column Name
public static final String HOARDING_ID = "_hoardingid";
public static final String AUDIT_DATE = "_auditdate";
public static final String STATE = "_state";
public static final String DISTRICT = "_district";
public static final String LATITUDE = "_latitude";
public static final String LONGITUDE = "_longitude";
public static final String CELLID_LOCATIONID = "_celllocid";
public static final String CREATED_DATE = "_createddate";
public static final String IMAGEFILENAME = "_imagefilename";
public static final String IMAGEURI = "_imageuri";
// Table Create Statements
// Audit table create statement
public static final String CREATE_AUDITDATAABLE = "create table "
+ AUDIT_TABLE + " (" + HOARDING_ID + " INTEGER PRIMARY KEY, "
+ AUDIT_DATE + " DATETIME " + STATE + " text, " + DISTRICT
+ " text, " + LATITUDE + " real, " + LONGITUDE + " real, "
+ CELLID_LOCATIONID + " text, " + CREATED_DATE + " DATETIME "
+ ");";
public void insertCustomerData(HoardingDetail datalist) {
openToWrite();
try {
ContentValues values = new ContentValues();
// int size = datalist.size();
db.delete(AUDIT_TABLE, "1", null);
values.put(HOARDING_ID, datalist.getHoardingId());
values.put(AUDIT_DATE, datalist.getAuditDate());
values.put(STATE, datalist.getState());
values.put(DISTRICT, datalist.getDistrict());
values.put(LATITUDE, datalist.getLatitiude());
values.put(LONGITUDE, datalist.getLongitude());
values.put(CELLID_LOCATIONID, datalist.getCellId_cellLocation());
values.put(CREATED_DATE, datalist.getCreatedDate());
long t = db.insert(AUDIT_TABLE, null, values);
} catch (Exception e) {
e.printStackTrace();
return;
} finally {
close();
}
}
在这一切之后我得到像这样的错误..
table audit_table没有名为_state
的列插入_latitude = 878 _state = Rajasthan _hoardingid = 235 _createddate = 2014-02-12 09:45:09 _auditdate = 2014-02-12 09:45:09 _longitude = 768 _district = Buldana _celllocid = android.database.sqlite.SQLiteException:table audit_table没有名为_state(code 1)的列:,编译时:INSERT INTO
audit_table(_latitude,_state,_hoardingid,_createddate,_auditdate,_longitude,_district,_ celllocid)VALUES(?,?,?,?,?,?,?,?)
请帮帮我...... 谢谢,
答案 0 :(得分:0)
您的表创建语句中缺少逗号。而不是
+ AUDIT_DATE + " DATETIME " + STATE + " text,
使用
+ AUDIT_DATE + " DATETIME, " + STATE + " text,
答案 1 :(得分:0)
你应该替换
"create table "
+ AUDIT_TABLE + " (" + HOARDING_ID + " INTEGER PRIMARY KEY, "
+ AUDIT_DATE + " DATETIME " + STATE + " text, " + DISTRICT
+ " text, " + LATITUDE + " real, " + LONGITUDE + " real, "
+ CELLID_LOCATIONID + " text, " + CREATED_DATE + " DATETIME "
+ ");";
使用
"create table "
+ AUDIT_TABLE + " (" + HOARDING_ID + " INTEGER PRIMARY KEY, "
+ AUDIT_DATE + " DATETIME, " + STATE + " text, " + DISTRICT
+ " text, " + LATITUDE + " real, " + LONGITUDE + " real, "
+ CELLID_LOCATIONID + " text, " + CREATED_DATE + " DATETIME "
+ ");";
您在 AUDIT_DATE +"之后错过了逗号。您的查询中的DATETIME,"