【发布时间】:2014-04-16 18:06:57
【问题描述】:
目前在我的 android 中的 SQLite 数据库中存在问题,当我尝试运行比较时,我收到以下错误: 引起:android.database.sqlite.SQLiteException:靠近“@hotmail”:语法错误:,编译时:SELECT DISTINCT _id,userName,password FROM userTable WHERE userName=djdss@hotmail.comAND password=shshsh
我的搜索是:
public boolean getUserNameAndPassword(String userName, String Password) throws SQLException {
Cursor mCursor =
db.query(true, TABLE_NAME, new String[] {KEY_ROWID,USER,
PWD},USER + "=" + userName + "AND password=" + Password, null,
null, null, null, null);
if (mCursor.getCount() > 0)
{
return true;
}
return false;}
我尝试运行它是:
boolean signIn = dbHelper.getUserNameAndPassword(mEmail, mPassword);
if (signIn){
Toast.makeText(getBaseContext(),"Sign in successful",Toast.LENGTH_LONG).show();
}else {Toast.makeText(getBaseContext(),"Sign in failed",Toast.LENGTH_LONG).show();}
提前致谢!
【问题讨论】:
-
这正是你应该使用
selectionArgs和?的原因。
标签: android sql eclipse sqlite