没有列名称存在

时间:2015-10-04 18:25:35

标签: java android sqlite

错误:没有名为Base Exists的列。 我认为它的间距问题,因为我提到了许多其他问题,但我无法解决这个问题。我有9个列名为:名称,数字,地址,类型,浇头,基数,大小,数量,TotalAmount 表格创建的逻辑:    package example.lapizzariahouse;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DBHelper extends SQLiteOpenHelper{

private static final int DB_version=1;
private static final String DB_name="Customer";
private static final String table="Cust_Details";
private static final String name="Name";
private static final String phone="Number";
private static final String address="Address";
private static final String type="Type";
private static final String topping="Toppings";
private static final String base="Base";
private static final String size="Size";
private static final String quantity="Quantity";
private static final String total="TotalAmount";

public DBHelper(Context context) {
    super(context, DB_name, null, DB_version);
    // TODO Auto-generated constructor stub

}

@Override
public void onCreate(SQLiteDatabase db) {
    // TODO Auto-generated method stub
    String Create_Table="CREATE TABLE "+table + "(" + name + " TEXT, " + phone + " TEXT, " + address + " TEXT, " + type + " TEXT, " + topping + " TEXT, " + base + " TEXT, " + size + " TEXT, " + quantity + " TEXT, " + total + " TEXT "+");";
    db.execSQL(Create_Table);               
}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    // TODO Auto-generated method stub
    db.execSQL("DROP TABLE IF EXISTS"+table);
    onCreate(db);
}
public void addDetails(CustomerDetail customer) {
    // TODO Auto-generated method stub
    SQLiteDatabase db=this.getWritableDatabase();
    ContentValues values=new ContentValues();

    values.put(name, customer.getName());
    values.put(phone, customer.getPhoneNumber());
    values.put(address, customer.getAdd());
    values.put(type, customer.getType());
    values.put(topping, customer.getTopping());
    values.put(base, customer.getBase());
    values.put(size, customer.getSize());
    values.put(quantity, customer.getQuantity());
    values.put(total, customer.getTotal());
     db.insert(table, null, values);
    db.close();
}

}

0 个答案:

没有答案