Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正试图用他的名字来获取用户:
public Cursor GetUser(String username) { return m_dataBase.rawQuery("SELECT * FROM users WHERE name = \' ? \'", new String[] { username }); }
但后来我得到一个异常“绑定或列索引超出范围”。我的代码有什么问题?
您正在尝试使用参数,但这些参数永远不需要被引用。您的查询实际上搜索名为“ ?”(带有空格)的用户。
?
只需使用"SELECT * FROM users WHERE name = ?".
"SELECT * FROM users WHERE name = ?"