mohan
mohan

Reputation: 13165

sqlite error in android

I am getting the value from webservice. I am storing in sqlite. While storing in sqlite, I am getting an error. even I replaced single quote with "\'". Which characters are not supported in sqlite?

My error is:

03-26 13:22:22.478: WARN/System.err(311): android.database.sqlite.SQLiteException: near "s": syntax error:

My insert statement is:

myDB.execSQL("INSERT INTO "+TableName
                     +"("+fieldname+")"
                     +" VALUES ('"+(homevalue)+"');");

Can anybody tell what to do or give an example?

Upvotes: 0

Views: 486

Answers (3)

varun bhardwaj
varun bhardwaj

Reputation: 1522

there is a name which is like "name's" i.e this single quote is problem

Upvotes: 1

Heba
Heba

Reputation: 219

I am just a beginner, but i think you should write it like this:

"INSERT INTO " + tableName + "(" + feildName + ") VALUES ('" + homeValue + "');"

you put () around the homeValue

Upvotes: 0

lawal
lawal

Reputation: 992

Maybe one of your string TableName, fieldname or homevalue contains some quotation. print out the query first and see.

Upvotes: 0

Related Questions