Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I get syntax error code(1) for the following:
C#
private static  final  String TABLE_NAME="VIVZTABLE";
    private static  final  String UID="_id";
    private static  final  String NAME="name";
    private static  final  String CREATE_TABLE="CREATE TABLE" +TABLE_NAME+ " (" +UID+ "INTEGER PRIMARY KEY AUTOINCREMENT," +NAME+ "VARCHAR(255));";
Posted

1 solution

Change from "CREATE TABLE" to "CREATE TABLE " (that is append a blank).
(as well change "INTEGER PRIMARY KEY AUTOINCREMENT," into " INTEGER PRIMARY KEY AUTOINCREMENT," and "VARCHAR(255));" into " VARCHAR(255));", that is add a blank in front of the strings).
 
Share this answer
 
Comments
S.Rajendran from Coimbatore 10-Mar-15 6:12am    
I did like as you said ie. a blank in front of strings, but not helping:
private static final String CREATE_TABLE= " CREATE TABLE" +TABLE_NAME+ "
(" +UID+ " INTEGER PRIMARY KEY AUTOINCREMENT," +NAME+ " VARCHAR(255));";
CPallini 10-Mar-15 6:18am    
you didn't do what I suggested. You have to put a trailing blank in the first string, that is you should write "CREATE TABLE ". The underlying reason is keywords MUST be separated from identifiers.
S.Rajendran from Coimbatore 10-Mar-15 6:45am    
Thanks it works. I have same type issue with drop table too.
private static final String DROP_TABLE= "DROP TABLE " +TABLE_NAME+" IF EXISTS";
CPallini 10-Mar-15 6:51am    
According to the documentation,
https://www.sqlite.org/lang_droptable.html
you should write
private static final String DROP_TABLE= "DROP TABLE IF EXISTS " + TABLE_NAME;
S.Rajendran from Coimbatore 10-Mar-15 7:04am    
Thanks.It works.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900