I’ve created this table in android:
String CREATE_TABLE="CREATE TABLE " + db_NAME + " ("
+ row_ID + " INT PRIMARY KEY AUTOINCREMENT,"
+ row_NAME + " TEXT, "
+ row_EMAIL + " TEXT, "
+ row_WEBSITE + " TEXT, "
+ row_TELEPHONE1 + " TEXT, "
+ row_TELEPHONE2 + " TEXT, "
+ row_TELEPHONE3 + " TEXT, "
+ row_TELEPHONE4 + " TEXT, "
+ row_TELEPHONE5 + " TEXT;";
db_name.execSQL(CREATE_TABLE);
and I’m trying to isert the following data:
Name: Ahlam M. Hussain
Email: ahlam@ahlam.ahlam
Website: http://www.ahlam.com
telephone#1: 123456789
telephone#2: 0987654321
telephone#3:
telephone#4:
telephone#5:
using the following string:
String sql_entry = String.format("Insert into %s (%s, %s, %s, %s, %s, %s, %s, %s) values (%s, %s, %s, %s, %s, %s, %s, %s);",tab_NAME, row_NAME, row_EMAIL, row_WEBSITE, row_TELEPHONE1, row_TELEPHONE2, row_TELEPHONE3, row_TELEPHONE4, row_TELEPHONE5, name, email, website, telephone1, telephone2, telephone3,telephone4, telephone5);
ourDatabase.execSQL(sql_entry);
where : ( row_NAME, row_EMAIL, row_WEBSITE, row_TELEPHONE1, row_TELEPHONE2, row_TELEPHONE3, row_TELEPHONE4, row_TELEPHONE5) are the columns names’
and : (name, email, website, telephone1, telephone2, telephone3,telephone4, telephone5) are the data intended to be inserted to the database
when I run the application, I got an error says:
SQLiteLog (1) near "M" : syntax error
so what is the problem ???
Enclose the non-numeric value in single quotes.