Home > DeveloperSection > Forums > SQLiteException: no such column
Allen Scott

Total Post:36

Points:254
Posted on    November-17-2014 3:12 AM

 Android Excel  Sqlite 
Ratings:


 1 Reply(s)
 910  View(s)
Rate this:

I have the below method that when executed gives the error:

11-09 12:11:17.578: E/AndroidRuntime(21018): Caused by: android.database.sqlite.SQLiteException: no such column: happy (code 1): , while compiling: select * from Bank where english = happy

The method is:

public boolean BankHas(Word currentWord) {

        openDataBase();

        Cursor cursor = myDataBase.rawQuery("select * from Bank where english = " + currentWord.english, null);

        return cursor.moveToFirst();

    }

My table scheme:

CREATE TABLE `Bank` (

    `english`   TEXT

);



Kamlakar Singh
Kamlakar Singh

Total Post:28

Points:196
Posted on    November-17-2014 6:11 AM

you missed single quote,so change

"select * from Bank where english = " + currentWord.english

to

"select * from Bank where english ='" + currentWord.english + "'"

Or recommended solution is to use parameterized query as

Cursor cursor = myDataBase.rawQuery("select * from Bank where english =? ", new String [] {currentWord.english});

And change your create table from

CREATE TABLE `Bank` (

    `english`   TEXT

);

to

CREATE TABLE Bank (

    english TEXT

);


Don't want to miss updates? Please click the below button!

Follow MindStick