我想從sqlite的數據獲取usermail當我選擇的用戶名我想這碼得到錯誤如何獲取電子郵件地址作爲用戶名每
android.database.sqlite.SQLiteException: no such column: royal (code 1): , while compiling: SELECT userName, compMail FROM Records WHERE userName= royal
DBController.java
public String returnickname(long l) {
// TODO Auto-generated method stub
String[] coloumns = new String[] { COLUMN_NAME, COLUMN_TYPE,COLUMN_COMP_MAIL };//calling elements in an array
Cursor c = db.query(DATABASE_NAME, coloumns,COLUMN_NAME + "=" + l, null, null, null, null);
if (c != null) {
c.moveToFirst();
String nickname = c.getString(2); // since name is in position 2 ie 3rd coloumn
return nickname;
}
return null;
}
VehicleReceipt.java
if (spinner.getId()== R.id.insu_comp_spinner) {
String label = parent.getItemAtPosition(position).toString();
long l=Long.parseLong(label);
String returnedname=controller.returnickname(l);
editICM.setText(returnedname);
我想通過微調選擇
來提取數據例如:select contact_no where name ='ram';
當我選擇ram set rams contact_no來編輯文本。
您還沒有表現出正確的代碼;一個'long'變量不能有'royal'的值。 –