SQLiteException syntax error unclear - android

I get
android.database.sqlite.SQLiteException: near "WHERE": syntax error (code 1): , while compiling: insert or replace into taeglich (datum, a, b, c, d) values ('29.4.2017', '10 ml f\n', '0.0', '0.0', '0.0') WHERE datum = '29.4.2017';
Do you see the syntax error?

Remove the WHERE clauses
insert or replace into taeglich VALUES ('29.4.2017', '10 ml f\n', '0.0', '0.0', '0.0');

Related

Android Studio Database SQLite Error

i want to build a database system with android studio, so i follow a step on someone blog.
When i start to save a data that i have inputted from my phone, the data cannot saved to the database.
Here is the log cat when i run my app
05-27 17:01:26.579 10597-10597/com.example.opec.menuprototype E/SQLiteLog: (1) table MenuTable has no column named menu_name
05-27 17:01:26.594 10597-10597/com.example.opec.menuprototype E/SQLiteDatabase: Error inserting menu_name=migor menu_id=1st menu_desc=mie menu_price=12000
android.database.sqlite.SQLiteException: table MenuTable has no column named menu_name (code 1): , while compiling: INSERT INTO MenuTable(menu_name,menu_id,menu_desc,menu_price) VALUES (?,?,?,?)
#################################################################
Error Code : 1 (SQLITE_ERROR)
Caused By : SQL(query) error or missing database.
(table MenuTable has no column named menu_name (code 1): , while compiling: INSERT INTO MenuTable(menu_name,menu_id,menu_desc,menu_price) VALUES (?,?,?,?))
Which part of the code you need to look up ? i will get it for you.
Replace this line
Context context = View.getRootView.getContext();
With this line
Context context = v.getRootView().getContext();

escape/replace apostrophe is not working

I am using the following line
memo = etMemo.getText().toString().replace("'", "\'");
because apostrophes are causing errors in my app. Even doing this replace though, I am still receiving an error.
android.database.sqlite.SQLiteException: near "s": syntax error (code 1): , while compiling: INSERT INTO [Trst](credit, memo, timestamp) VALUES ('10.0', 'Test's', '07/29/2014')
Does anyone know why this wouldnt be working properly?
Try
memo = etMemo.getText().toString().replace("'", "\'\'"); // one apostrophe -> two apostrophes

SQLiteException: near "-": syntax error

I'm getting this exception when doing a create view sentence:
04-10 10:09:55.475: E/AndroidRuntime(15451): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mo.activity}: android.database.sqlite.SQLiteException: near "-": syntax error (code 1): , while compiling: CREATE VIEW vNa-MarcadbRESID1dataV18 AS SELECT * FROM ITEMS WHERE 1 AND ( 1 != 1 OR Column7 = 1 )
Where is the problem?
vNa-MarcadbRESID1dataV18 is not a valid name for a View in sqlite?
Identifiers such as view names cannot contain - - it parses as subtraction expression. Either rename it or quote it in `backticks` or "double quotes".

android.database.sqlite.SQLiteException: no such column: ۱۵۳۶۱۹۸۶۸۴۰۰۸۵۴۲۵۴۱

all.
I've found in bugsense for Android application this exeception:
android.database.sqlite.SQLiteException: no such column: ۱۵۳۶۱۹۸۶۸۴۰۰۸۵۴۲۵۴۱ (code 1): , while compiling:
SELECT * FROM by_istin_android_xcore_source_DataSourceRequestEntity WHERE (_id = -۱۵۳۶۱۹۸۶۸۴۰۰
Seems like try to select with filter by arabic number.
Someone see it before?
If _id is a numeric column, you must change your code to generate numbers with ASCII digits.
If _id contains strings, you must change your code to 'quote' the string.

SQL Syntax Error Android

I am getting an SQL syntax error but I'm not quite sure why. This is the error code I am obtaining;
android.database.sqlite.SQLiteException: near "GCSE": syntax error (code 1): , while compiling: SELECT foreign_word,english_meaning,correct FROM vocab_words WHERE name = AQA GCSE Spanish Higher
Any suggestions to fix this - I don't know what the error is?
when the column's data type is string, its value should be wrapped with single quote.
SELECT foreign_word,english_meaning,correct
FROM vocab_words
WHERE name = 'AQA GCSE Spanish Higher'

Categories

Resources