Im trying to add a table to my sqlite db.
public class PendingOrdersDbHandler extends SQLiteOpenHelper {
// Database Version
private static final int DATABASE_VERSION = 1;
// Database Name
private static final String DATABASE_NAME = "vaighai";
// notifications table name
private static final String TABLE_PENDINGORDERS = "pendingOrders";
// pending orders Table Columns names
private static final String KEY_ID = "id";
private static final String KEY_SHIPMENT_NO = "shipmentNo";
private static final String KEY_SHIPMENT_REF_NO = "shipmentRefNo";
private static final String KEY_PRO_INV_NO = "proformoInvoiceNumber";
private static final String KEY_PRO_INV_DATE = "proformoInvoiceDate";
private static final String KEY_SHIPMENT_DATE = "shipmentDate";
private static final String KEY_PT_OF_CONTACT = "pointOfContact";
private static final String KEY_PRODUCT = "product";
private static final String KEY_QTY = "quantity";
private static final String KEY_RATE = "rate";
private static final String KEY_AMOUNT = "amount";
private static final String KEY_PRODUCT_IMG = "productImage";
private static final String KEY_SHIPMENT_STAT = "shipmentStatus";
public PendingOrdersDbHandler(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
public PendingOrdersDbHandler(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
String CREATE_CONTACTS_TABLE = "CREATE TABLE if not exists " + TABLE_PENDINGORDERS + "("
+ KEY_ID + " INTEGER PRIMARY KEY,"
+ KEY_SHIPMENT_NO + " TEXT,"
+ KEY_SHIPMENT_REF_NO + " TEXT"
+ KEY_PRO_INV_NO + " TEXT,"
+ KEY_PRO_INV_DATE + " TEXT,"
+ KEY_SHIPMENT_DATE + " TEXT,"
+ KEY_PT_OF_CONTACT + " TEXT,"
+ KEY_PRODUCT + " TEXT,"
+ KEY_QTY + " TEXT,"
+ KEY_RATE + " TEXT,"
+ KEY_AMOUNT + " TEXT,"
+ KEY_PRODUCT_IMG + " TEXT,"
+ KEY_SHIPMENT_STAT + " TEXT,"
+ ")";
db.execSQL(CREATE_CONTACTS_TABLE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// Drop older table if existed
db.execSQL("DROP TABLE IF EXISTS " + TABLE_PENDINGORDERS);
// Create tables again
onCreate(db);
}
/**
* CRUD(Create, Read, Update, Delete) Operations
*/
// Adding new contact
// Adding new pending order
public void addPendingOrders(PendingOrdersDao pendingOrders) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(KEY_ID,pendingOrders.getId());
values.put(KEY_SHIPMENT_NO, pendingOrders.getSipmentNo());
values.put(KEY_SHIPMENT_REF_NO, pendingOrders.getShipmentRefNo());
values.put(KEY_PRO_INV_NO, pendingOrders.getProformoInvoiceNumber());
values.put(KEY_PRO_INV_DATE, pendingOrders.getProformoInvoiceDate());
values.put(KEY_SHIPMENT_DATE, pendingOrders.getShipmentDate());
values.put(KEY_PT_OF_CONTACT, pendingOrders.getPointOfContact());
values.put(KEY_PRODUCT, pendingOrders.getProduct());
values.put(KEY_QTY, pendingOrders.getQuantity());
values.put(KEY_RATE,pendingOrders.get_rate());
values.put(KEY_AMOUNT, pendingOrders.getAmount());
values.put(KEY_PRODUCT_IMG, pendingOrders.getProductImage());
values.put(KEY_SHIPMENT_STAT, pendingOrders.getShipmentStatus());
// Inserting Row
db.insert(TABLE_PENDINGORDERS, null, values);
db.close(); // Closing database connection
}
}
I have posted the code that i used to create table. Exception
android.database.sqlite.SQLiteException: near ")": syntax error (code 1): , while compiling: CREATE TABLE pendingOrders(id INTEGER PRIMARY KEY,shipmentNo TEXT,shipmentRefNo TEXTproformoInvoiceNumber TEXT,proformoInvoiceDate TEXT,shipmentDate TEXT,pointOfContact TEXT,product TEXT,quantity TEXT,rate TEXT,amount TEXT,productImage TEXT,shipmentStatus TEXT,)
Its not be able to create a table pendingOrders within the database. I have also tried adding 'check if' command of sqlite so as to check if the table already exists and create table if doesn't exist. But still, the problem persists.
Aucun commentaire:
Enregistrer un commentaire