Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting No such column error
    primarykey
    data
    text
    <p>In the database of my Android App, I am trying to update the value of specific cell of the column but getting error <code>NO SUCH COLUMN</code>.</p> <p>I am trying this query in my Database Handler class,</p> <pre><code>public void addVote(String politicianname,int vote) { ContentValues values=new ContentValues(); values.put(KEY_TOTALVOTES, vote); db.update(TABLE_POLLINGVOTES, values, KEY_POLITICIANNAMES=politicianname, null); } </code></pre> <p>This is where i am creating table,</p> <pre><code>String CREATE_POLLINGVOTES_TABLE="CREATE TABLE pollingvotes(politiciannames TEXT, totalvotes NUMERIC)"; db.execSQL(CREATE_POLLINGVOTES_TABLE); </code></pre> <p>This is where is adding names in <code>TABLE_POLLINGVOTES</code>, </p> <pre><code>public void addPoliticianNames() //This method is called before calling `addVote` Method { deleteTable(); String[] a = {"I","Me","Myself"}; ContentValues values = new ContentValues(); for (int i = 0; i &lt; a.length; i++) { values.put(KEY_POLITICIANNAMES, a[i]); db.insert(TABLE_POLLINGVOTES, null, values); } } </code></pre> <p>Here is my LogCat,</p> <pre><code>10-31 05:35:45.463: E/AndroidRuntime(1169): FATAL EXCEPTION: main 10-31 05:35:45.463: E/AndroidRuntime(1169): android.database.sqlite.SQLiteException: no such column: I (code 1): , while compiling: UPDATE pollingvotes SET totalvotes=? WHERE I 10-31 05:35:45.463: E/AndroidRuntime(1169): at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method) 10-31 05:35:45.463: E/AndroidRuntime(1169): at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:882) 10-31 05:35:45.463: E/AndroidRuntime(1169): at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:493) 10-31 05:35:45.463: E/AndroidRuntime(1169): at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588) 10-31 05:35:45.463: E/AndroidRuntime(1169): at android.database.sqlite.SQLiteProgram.&lt;init&gt;(SQLiteProgram.java:58) 10-31 05:35:45.463: E/AndroidRuntime(1169): at android.database.sqlite.SQLiteStatement.&lt;init&gt;(SQLiteStatement.java:31) 10-31 05:35:45.463: E/AndroidRuntime(1169): at android.database.sqlite.SQLiteDatabase.updateWithOnConflict(SQLiteDatabase.java:1563) 10-31 05:35:45.463: E/AndroidRuntime(1169): at android.database.sqlite.SQLiteDatabase.update(SQLiteDatabase.java:1514) 10-31 05:35:45.463: E/AndroidRuntime(1169): at com.example.polling.DBAdapter.addVote(DBAdapter.java:134) 10-31 05:35:45.463: E/AndroidRuntime(1169): at com.example.polling.VotePage.onClick(VotePage.java:42) 10-31 05:35:45.463: E/AndroidRuntime(1169): at android.view.View.performClick(View.java:4204) 10-31 05:35:45.463: E/AndroidRuntime(1169): at android.view.View$PerformClick.run(View.java:17355) 10-31 05:35:45.463: E/AndroidRuntime(1169): at android.os.Handler.handleCallback(Handler.java:725) 10-31 05:35:45.463: E/AndroidRuntime(1169): at android.os.Handler.dispatchMessage(Handler.java:92) 10-31 05:35:45.463: E/AndroidRuntime(1169): at android.os.Looper.loop(Looper.java:137) 10-31 05:35:45.463: E/AndroidRuntime(1169): at android.app.ActivityThread.main(ActivityThread.java:5041) 10-31 05:35:45.463: E/AndroidRuntime(1169): at java.lang.reflect.Method.invokeNative(Native Method) 10-31 05:35:45.463: E/AndroidRuntime(1169): at java.lang.reflect.Method.invoke(Method.java:511) 10-31 05:35:45.463: E/AndroidRuntime(1169): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 10-31 05:35:45.463: E/AndroidRuntime(1169): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) </code></pre> <p>This is how my database looks,</p> <p><img src="https://i.stack.imgur.com/qKpBo.png" alt="enter image description here"></p> <p>Where I am getting wrong,</p> <p>Please help,</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload