Why Am I Getting A Column Doesnt Exist Error With The Name Of The Table
Hi guys Im trying to retrieve some data I inserted into a database in a previous activity. This is my code to Retrieve the data public class Display_data extends AppCompatActivity
Solution 1:
Put aa1000 into single quotes ('aa1000'):
Your SQL query should look like:
Select Train_name From Train_list Where Train_no='aa1000'So modify your select string inside db.rawQuery:
"Select Train_name From Train_list Where Train_no='"+message.substring(0,(message.length()-3))+"'";
However it is not advised to use rawQuery for select queries and passing parameters this way, better learn use the query method
Solution 2:
First try to understand rawQuery method declaration then implement as below :
Cursor rawQuery (String sql, String[] selectionArgs)
rawQuery("SELECT Train_name FROM Train_list WHERE Train_no = ?", newString[] {message.substring(0,(message.length()-3)});
Note : ' ? ' replace selectionArgs actual value when query run into database
Post a Comment for "Why Am I Getting A Column Doesnt Exist Error With The Name Of The Table"