SQLite Exception : no such column
You are getting this error because you are trying to update a column's value with a string/text without providing the correct format.
You have to single quote (') the jsonArrayString on both sides in order to be recognized as a text value. You should always wrap your text values with single quotes in SQL queries.
Specifically:
'[{"id":206406,"name":"1","author":"1"}]'
Although, hardcoding your queries is a bad practice that you should always avoid. Your queries are vulnerable to SQL injection attacks. This can be easily avoided by binding the parameters.
For example, instead of execSQL you can use the update method of SQLiteDatabase.
SQLite database No such column error on verified existing column
The value a886 should be a text/string literal not a numeric literal. Therefore it should be enclosed in single quotes. The errors are because:-
a886 fails with no column found as it's taken to be a column name as it's not a literal.
whilst 88a6 is first not a valid literal (due to the a) and therefore a column name but then an invalid column (cannot start with a numeric unless enclosed) name and thus not a known token.
See Literal Values (Constants)
You could fix this using (enclosing the threadId in single quotes ) :-
String selectQuery = "SELECT * FROM " + Conversations.TABLE_NAME + " WHERE " +
Conversations.COLUMN_THREAD_ID + " LIKE '" + threadId + "'";
However, it is recommended to use bound parameters to protect against SQL Injection.
Thus it would be recommended to use :-
String selectQuery = "SELECT * FROM " + Conversations.TABLE_NAME + " WHERE " +
Conversations.COLUMN_THREAD_ID + " LIKE ?";
along with :-
Cursor cursor = db.rawQuery(selectQuery, new String[]{threadId});
- i.e. the ? is replaced by the threadId value properly enclosed.
You may wish to consider using the convenience query method rather than rawQuery, this would be :-
Cursor cursor = db.query(Conversations.TABLE_NAME,null,Conversations.COLUMN_THREAD_ID + " LIKE ?", new String[]{theadId},null,null, null);
- The SQL is built for you.
It almost looks like mixing letters and numbers might be part of the reason here but should not be as the column was created to hold TEXT datatype.
SQlite has no issue storing any value in any type. The type, which itself can be virtually anything (rules are used to determine the resultant type), is only an indication of the value that will be stored. The only exception is that a rowid or an alias of the rowid MUST be an integer value (your id column is an alias of the rowid column).
android.database.sqlite.SQLiteException: no such column or name
The cause is that you are passing a value as if it were a column name (and hence the error), that is it is a string/text value that is not enclosed in single quotes (which are used to distinguish text from entity names (columns, tables views etc)).
Use :-
int res = db.update(Teacher_table,args,Teacher_name + "='" + Name + "'",null);
Or better :-
int res = db.update(Teacher_table,args,Teacher_name + "=?",new String[]{name});
- The latter puts the quotes around the value and protects against SQLInjection attacks.
- the ? represents a bound value i.e. one that is replaced according to the values via the 4th parameter. The 3rd parameter being an array of Strings each will replace the repective ? in the where clause (3rd parameter)
SQLite Exception no such column when trying to select
What's happening here is that SQLite thinks that 'pb3874' is actually a column name, rather than a string/text literal.
To specify that it's a text literal, you'll want to ensure your text value is wrapped in the appropriate single quotes:
To prevent SQL injection attacks, whenever you're taking input from the user, use a parameterized query:
("select count(*) from usertable where " + KEY_STUDID + "=?", studid);
Without parameterization (very much discouraged when taking user input):
("select count(*) from usertable where " + KEY_STUDID + "='" + studid + "'", null);
The reason your numeric values didn't produce this: SQLite converted those numeric literals for you.
sqlite select no such column
As it is, the query that your code produces is :
SELECT * FROM friends WHERE name LIKE David;
sqlite does consider unquoted David
as a column name, hence the error you are getting.
You probably want this instead :
SELECT * FROM friends WHERE name LIKE 'David';
LIKE
without wildcard on the right side does not really make sense, so that could be either of the following queries, depending if you want exact match or not
SELECT * FROM friends WHERE name LIKE '%David%';
SELECT * FROM friends WHERE name = 'David';
To generate the query, you could use the following code :
"SELECT * FROM friends WHERE name LIKE '%" + texts + "%';"
"SELECT * FROM friends WHERE name = '" + texts + "';"
No such column, SQLite GORM
Most likely your column name will be image_id
.
As the gorm documentation says:
Column db name uses the field’s name’s snake_case by convention.
The tables get generated this way when you use gorm's auto migrate feature.
For further info see: https://gorm.io/docs/conventions.html#Column-Name
Related Topics
Using Adb Logcat with a Real Phone (And Not the Emulator)
Getting Permission Denial Exception
How Does Native Android Code Written for Arm Run on X86
Actionbarsherlock - How to Set the Padding of Each Actionbar's Icon
Failed to Find Target with Hash String 'Android-22'
How to Keep a Countdowntimer Running Even If the App Is Closed
How to Load Bufferedimage in Android
First Letter Capitalization for Edittext
Gradle and Multi-Project Structure
How to Check If Facebook Is Installed Android
How to Create a Database in Android
Continually Running Background Service
Programmatically Add View One Below Other in Relative Layout
Android Sms Receiver Not Working
Android Studio: Gradle: Error: Cannot Find Symbol Variable
Android How to Replace the Deprecated Tabhost
Error: Failed to Resolve: Com.Android.Support:Appcompat-V7:29.0.1'