附近&QUOT SQLite的语法错误; CREATE TABLE"

编程入门 行业动态 更新时间:2024-10-26 15:24:49
本文介绍了附近&QUOT SQLite的语法错误; CREATE TABLE"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

下面是我的code:

String CREATE_DATABASE = "CREATE TABLE " + TABLE_NAME + "(" + KEY_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + "title TEXT, "+ "author TEXT, "+ "state TEXT);"; db.execSQL(CREATE_DATABASE);

在LogCat中表示:12-11 23:43:50.553:E / AndroidRuntime(3706):android.database.sqlite.SQLiteException:近CREATE TABLE:语法错误(code 1),在编译:CREATE TABLE PapersTable(_id INTEGER PRIMARY KEY AUTOINCREMENT,标题文本,作者文字,状态TEXT);

The LogCat says : 12-11 23:43:50.553: E/AndroidRuntime(3706): android.database.sqlite.SQLiteException: near "CREATE TABLE": syntax error (code 1): , while compiling: CREATE TABLE PapersTable(_id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT, author TEXT, state TEXT);

推荐答案

的 CREATE TABLE 语法都是正确的,你已经张贴了。

The CREATE TABLE syntax is all right as you've posted it.

我怀疑之间有一个不间断空格(ASCII 0XA0)创建和 TABLE 。与常规的空格(ASCII为0x20)替换它。这可以解释您发布的语法错误:解析器治疗 CREATE TABLE 作为一个单一的未知的令牌,而不是两个单独的已知的标记创建和 TABLE 。

I suspect there's a non-breaking space (ASCII 0xA0) between CREATE and TABLE. Replace it with the regular space (ASCII 0x20). That would explain the syntax error you posted: parser is treating CREATE TABLE as a single unknown token and not as two separate known tokens CREATE and TABLE.

什么是绝对错误的是,你叫 db.close()在 SQLiteDatabase分贝传过来的参数给你的函数。您应该只关闭数据库已打开自己和关闭这种方式将导致异常,尽管不同的功能。

What is definitely wrong is that you call db.close() on the SQLiteDatabase db passed in as a parameter to your function. You should only close databases you opened yourself and closing it this way will lead to an exception, albeit a different one.

更多推荐

附近&QUOT SQLite的语法错误; CREATE TABLE"

本文发布于:2023-07-22 04:07:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1184010.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:语法错误   SQLite   QUOT   CREATE   TABLE

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!