Closed. This question is not reproducible or was caused by typos。它当前不接受答案。
                            
                        
                    
                
            
                    
                
                        
                            
                        
                    
                        
                            想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
                        
                        4年前关闭。
                    
                
        

这是日志猫:


  原因:android.database.sqlite.SQLiteException:无此类列:uname(代码1):,而在编译时:选择uname,则传递
  来自帐户


这是我在SqliteDatabase Helper中的代码:

public String searchPass(String uname)
{
    db = this.getReadableDatabase();
    String query = "select uname , pass from"+TABLE_NAME;
    Cursor cursor = db.rawQuery(query , null);
    String a, b;
    b = "not found";
    if (cursor.moveToFirst())
    {
        do {
            a = cursor.getString(0);
            b = cursor.getString(1);

            if (a.equals(uname))
            {
                b = cursor.getString(1);
                break;
            }
        }
        while (cursor.moveToNext());
    }
    return b;
}


这些是我的专栏:

     private static final int DATABASE_VERSION = 1;
     private static final String DATABASE_NAME = "echo_all.db";
     private static final String TABLE_NAME = "accounts";
     private static final String COLUMN_ID = "id";
     private static final String COLUMN_FIRST_NAME = "fname";
     private static final String COLUMN_LAST_NAME = "lname";
     private static final String COLUMN_USERNAME = "uname";
     private static final String COLUMN_EMAIL = "email";
     private static final String COLUMN_PASS = "pass";
     SQLiteDatabase db;
     private static final String TABLE_CREATE = "create table accounts (id integer primary key not null ," +
        "fname text not null , lname text not null , uname text not null , email text not null , pass text not null );";


我在使用“选择uname,从” + TABLE_NAME传递代码来解决日志猫错误时需要帮助。它在日志目录中将其标记为错误。

最佳答案

您在SQL中有问题。 from和TABLE_NAME之间应该有一个空格

代替

String query = "select uname , pass from" + TABLE_NAME;


使用

String query = "select uname , pass from " + TABLE_NAME;

关于java - 查询表时遇到麻烦:没有这样的列,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34261088/

10-10 11:43