1

the table is generated from xml and it look like this CREATE TABLE orders (id INTEGER AUTO-INCREMENT PRIMARY KEY , id_room INTEGER, nr_table INTEGER, id_user INTEGER, id_payment INTEGER, total INTEGER)

com.DataConnector.DataConnector.getInstance(getApplicationContext()).executeQuery("INSERT INTO sync_log (table_name,rec_id,upd,del,synchronized)" +"VALUES (\"orders\",2,1,0,0) ");

This one works without problem .

Boolean ab=com.DataConnector.DataConnector.getInstance(getApplicationContext()).executeQuery(
"INSERT INTO orders (id_room,nr_table,id_user,id_payment,total)" +"VALUES (1,1,1,0,100) ");

This throws

no such column: orders (code 1): , while compiling: INSERT INTO orders (id_room,nr_table,id_user,id_payment,total)VALUES (1,1,1,0,100)

Log.i("cursor id", cursor.getColumnName(0) + cursor.getColumnName(1) + cursor.getColumnName(2) + cursor.getColumnName(3) +cursor.getColumnName(4) + cursor.getColumnName(5));
returns `idid_roomnr_tableid_userid_paymenttotal

so i have the table, the columns

  • so the question is how can i solve the no such column problem – Matzy schneider Nov 02 '12 at 12:00
  • Have you verified the table, orders, and its columns? I'd check that first. – CM Kanode Nov 02 '12 at 12:05
  • `SELECT name FROM sqlite_master WHERE type='table' AND name='table_name';` yes if you think about this, and the return was a cursor with name colmun i don`t know if it is good?? – Matzy schneider Nov 02 '12 at 12:17
  • Your LogCat returned `id, id_room, nr_table, id_user, id_payment, total`, looks to me like you just need to add `id` to your insert statement with a value of null if autoincrementing. Have you tried this? – jnthnjns Nov 02 '12 at 12:57

4 Answers4

0

There is no space between "total)" and "VALUES" ?

Sam
  • 2,939
  • 19
  • 17
0

Should be a problem in the definition of the table. Make sure all columns are Integer.

Try to create again the table like this:

CREATE TABLE orders (id INTEGER PRIMARY KEY, id_room INTEGER, nr_table INTEGER, id_user INTEGER, id_payment INTEGER, total INTEGER)
Lo Juego
  • 1,305
  • 11
  • 12
  • total was NUMERIC, changed to INTEGER and the same problem:( but it was hopeful :) – Matzy schneider Nov 02 '12 at 12:24
  • Try to test insert only one column and then add more if the test succeed – Lo Juego Nov 02 '12 at 12:26
  • Publish the definition of that table in your question. Try to upgrade the version, and in the onupdate method force delete that table and create again (in your DB Manager definition) – Lo Juego Nov 02 '12 at 12:41
0

I guess you need to make use of the _id attribute in the table.

It is better always use the attribute _id in the table , if you are going to do process with cursors.

For your better understanding

See this discussion and go through this info. You may feel comfortable by using database, cursor and adapters in Android.

Community
  • 1
  • 1
Kartihkraj Duraisamy
  • 3,171
  • 2
  • 25
  • 36
0

Sorry boys problem solved, i had an UPDATE Trigger on orders table and there was a sintactical err