1

just like the title goes, I'm unable to key the email address into SQLite databases. The error is as followed:

02-01 09:49:52.300: I/SqliteDatabaseCpp(16157): sqlite returned: error code = 1, msg = near "@gmail": syntax error, db=/data/data/com.proj.db/databases/FormDetails

There is nothing wrong in the creating of database it's only recently that I add into the email column then this error comes out. Is it because the "@" sign cannot be keyed into the database?

My code for the table:

String insertNewFormDetails = "create table if not exists " + TABLE_NAME + " ( " + BaseColumns._ID + " integer primary key autoincrement, " 
                                                            + NAME + " text not null, "
                                                            + SCHOOL + " text not null, "
                                                            + CURRENTDATE + " text not null, "
                                                            + FORMTYPE + " text not null, "
                                                            + EMAIL + " text not null);";

    db.execSQL(insertNewFormDetails);
2
  • What is the value of insertNewFormDetails and each of the String variables you use to build it? Commented Feb 1, 2013 at 2:06
  • Note that your SQL statement is trying to create a table with some column names that come from other variables. This is not the same as inserting data, like the variable name suggests. Column names cannot contain the @ character. Commented Feb 1, 2013 at 2:07

1 Answer 1

2

Its not allowed to use the @ in column name like @Email but you can still use it by using square brackets arround the column name like [@email].

Valid:

[@Email]

InValid:

@Email

Please note that you need to reference this column like [@Email] in SQL queries and it will work.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.