lundi 6 avril 2015

SQLite Column not created

Ok so I have no idea what the problem is. I get an error saying that the sender_id column does not exist. I have two tables, the user table is created just fine and all the column names are constants.



public String CREATE_USER_TABLE = "CREATE TABLE " + TableData.TableInfo.USER_TABLE +
" ( "+ TableData.TableInfo.USER_NAME +" TEXT PRIMARY KEY, "
+ TableData.TableInfo.USER_PASS +" TEXT, "
+ TableData.TableInfo.USER_FNAME + " TEXT, "
+ TableData.TableInfo.USER_LNAME + " TEXT);";
//Create Message table
public String CREATE_MSG_TABLE = "CREATE TABLE " + TableData.TableInfo.MSG_TABLE +
" ( " + TableData.TableInfo.MESSAGE_ID + " INTEGER PRIMARY KEY, "
+ TableData.TableInfo.RECEIVER_ID + " TEXT, "
+ TableData.TableInfo.SENDER_ID + " TEXT, "
+ TableData.TableInfo.MESSAGE + " TEXT, "
+ TableData.TableInfo.STATUS + " INTEGER);";


The User table is created just fine and I have no issues accessing information. But I get errors trying to access the message table.



public void onCreate(SQLiteDatabase sdb){
sdb.execSQL(CREATE_USER_TABLE);
Log.d("Database operations", "Table1 created");
sdb.execSQL(CREATE_MSG_TABLE);
Log.d("Database operations", "Table2 created");

}


And this is where I query the table to add a row.



public void putInformationMsgTable(DatabaseOperations dop,String senderID,String receiverID, String text, int status)
{
SQLiteDatabase SQ = dop.getWritableDatabase();

SQ.execSQL("INSERT INTO " + TableData.TableInfo.MSG_TABLE +
" (" + TableData.TableInfo.MESSAGE_ID +
", " + TableData.TableInfo.RECEIVER_ID +
", " + TableData.TableInfo.SENDER_ID +
", " + TableData.TableInfo.MESSAGE +
", " + TableData.TableInfo.STATUS + ")" +
" VALUES (" + null + ", "
+ receiverID + ", "
+ senderID + ", "
+ text + ", "
+ status + ")");

Log.d("Database operations", "One row inserted into message table");
}


I know there are a lot of threads out there on this topic but both my professor and I are stumped. My syntax seems correct and there is no reason that this shouldn't work. Any thoughts?!


Aucun commentaire:

Enregistrer un commentaire