【问题标题】:Can't prepare PRAGMA queries on Android无法在 Android 上准备 PRAGMA 查询
【发布时间】:2010-03-05 20:43:23
【问题描述】:

有这条线

Cursor c = db.rawQuery("PRAGMA table_info(?)", new String[] {tableName});

得到这个: android.database.sqlite.SQLiteException: near "?": syntax error: , while compiling: PRAGMA table_info(?)

你知道为什么吗?

【问题讨论】:

    标签: android sqlite


    【解决方案1】:

    尝试在表名中临时硬连线。如果这样可行,那么您不能将位置参数用于 pragma 参数——您只需要自己进行一些字符串连接。

    【讨论】:

    • 就是这样。如果我使用 string.format 效果很好。要提交的错误。
    • 不确定这是 Android 限制还是 SQLite 限制。
    • 我在使用 bindargs 的 rawQuery 方面遇到了长期问题。它似乎至少在 OS 2.1 之前被破坏了。我总是不得不求助于脏字符串连接或 String.replace
    猜你喜欢
    • 1970-01-01
    • 2015-11-09
    • 1970-01-01
    • 1970-01-01
    • 2018-09-11
    • 2012-06-02
    • 1970-01-01
    • 1970-01-01
    • 2012-04-09
    相关资源
    最近更新 更多