Android SQLiteException:near"(&#34 ;:语法错误(代码1):

时间:2017-06-14 13:24:50

标签: android sqlite android-sqlite

我花了一些时间来解决这个问题,但我不知道我的sql创建条目中的问题在哪里..

错误:

transform

提前致谢

CODE:

func

2 个答案:

答案 0 :(得分:1)

如果您真的打算创建虚拟表,那么您将缺少“USING module_name”。请参阅here

如果您不打算创建虚拟表(可能是因为您使用的是Android),那么您应该从CREATE语句中删除“VIRTUAL”。语法为here

答案 1 :(得分:1)

您缺少CommerceSearchReaderDbHelper.CommerceNameSearchEntry._ID和TEXT_TYPE等之间的空格。请改用:

public static final String SQL_CREATE_ENTRIES =
            "CREATE VIRTUAL TABLE " + 
             CommerceSearchReaderDbHelper.CommerceNameSearchEntry.TABLE_NAME + " ( " + CommerceSearchReaderDbHelper.CommerceNameSearchEntry._ID          
             + " " + TEXT_TYPE +"  PRIMARY KEY," +
                    CommerceSearchReaderDbHelper.CommerceNameSearchEntry.COLUMN_ID + " " + INTEGER_TYPE + COMMA_SEP +
                    CommerceSearchReaderDbHelper.CommerceNameSearchEntry.COLUMN_NAME + " " + TEXT_TYPE + COMMA_SEP  +
                    CommerceSearchReaderDbHelper.CommerceNameSearchEntry.COLUMN_CATEGORY + " " + TEXT_TYPE + COMMA_SEP  +
                    CommerceSearchReaderDbHelper.CommerceNameSearchEntry.COLUMN_IMAGEREF + " " + TEXT_TYPE +
             " );";