SQLite column error: table XXX has no column named YYY

前端 未结 3 470
逝去的感伤
逝去的感伤 2021-01-29 07:47

I\'ve looked at the following, among others and have found nothing that matches my problem (as far as I can tell):

android.database.sqlite.SQLiteException: table X has n

相关标签:
3条回答
  • 2021-01-29 07:51

    This can happen when you are trying to insert the data into the table where the column name does not exist or maybe schema that you are trying to insert into has been changed with the latest sequelize.js code.

    Possible issue Examples:

    • Renamed column name (eg: earlier ID and now UUID)
    • New schema design or complete table schema change
    • Trying to insert the data with the wrong field name (eg: IDS: 1234) into the table with the column name (eg: ID: 1234)
    0 讨论(0)
  • 2021-01-29 08:07

    Looks like your values variable already have that value inside the object, check this :

    public void addVetInfo(String name, String address1, String address2, String city, String state, String zip, String phone, String email){
        try {
            db = this.getWritableDatabase();
            //INITIALIZE YOUR VARIABLE VALUES HERE
            ContentValues values = new ContentValues();
    
        //if(name == "Enter vet name") name = null;
        values.put(VET_NAME, name);
        //if(address1 == "Enter address 1" || address1 == " ") address1 = null;
        values.put(ADDRESS1, address1);
        //if(address2 == "Enter address 2") address2 = null;
        values.put(ADDRESS2, address2);
        //if(city == "Enter city") city = null;
        values.put(CITY, city);
        //if(state == "Enter state") state = null;
        values.put(CITY, state);
        //if(zip == "Enter zip") zip = null;
        values.put(ZIP_CODE, zip);
        //if(phone == "Enter phone number") phone = null;
        values.put(PHONE_NUMBER, phone);
        //if(email == "Enter email address") email = null;
        values.put(EMAIL_ADDRESS, email);
        db.insert(TABLE_VETS, null, values);
    } catch (SQLException e) {
        e.printStackTrace();
    }
    }
    
    0 讨论(0)
  • 2021-01-29 08:10

    For others who are having problems with this SQLite error, it appears that it was due in my case to having duplicate column names as pointed out by CL to my post. When I corrected that and reran the code, it worked fine, no error.

    So, make sure that your column names are correct for your insert statement.

    0 讨论(0)
提交回复
热议问题