Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android.database.sqlite.SQLiteException: no such column

when i execute this query i get 'android.database.sqlite.SQLiteException: no such column' what is the error?

    public Cursor Getupdate(String rid) throws SQLException 
        {

Cursor m1Cursor = db.rawQuery("SELECT _id FROM  Meeting   where meet="+rid , null);
    if (m1Cursor != null) {           
        if(m1Cursor.getCount() > 0)
        {

             m1Cursor.moveToFirst();
        }
    }
 return m1Cursor;
}

logcat

05-28 01:22:27.999: E/AndroidRuntime(1411): FATAL EXCEPTION: main
05-28 01:22:27.999: E/AndroidRuntime(1411): android.database.sqlite.SQLiteException: no such column: ttyuhomk: , while compiling: SELECT _id FROM  Meeting where meet=rage
like image 421
pantera Avatar asked May 29 '13 17:05

pantera


3 Answers

you need to use apostrophe(') in Where clause checking.. like

db.rawQuery("SELECT _id FROM  Meeting   where meet='"+rid+"'" , null);
like image 102
stinepike Avatar answered Oct 06 '22 00:10

stinepike


For string data type always use quotes like this '"+rid+"'" since rid is String you get error.

You should use +rid only if rid is int.

like image 22
Metalhead1247 Avatar answered Oct 06 '22 01:10

Metalhead1247


You can also use like this.

db.rawQuery("SELECT _id FROM  Meeting   where meet=?" ,
            new String [] {rid});

This will also solve for SQL injection problem.

like image 44
Thiha Zaw Avatar answered Oct 06 '22 00:10

Thiha Zaw