samedi 6 juin 2015

table Login has no column named A_NAME (code 1): , while compiling: INSERT INTO Login(A_NAME,A_PHONE) VALUES (?,?)

public class DBhandle  {

private static final String DATABASE_NAME = "restaurantdatabase";
private static final int DATABASE_VERSION = 1;
final Context context;
private SQLiteDatabase ourDatabase;

//table name
private static final String LOGIN_TABLE_NAME = "Login";

//login table column name
public static final String KEY_ROWID= "ID";
public static final String A_NAME = "admin_name";
public static final String A_PHONE = "admin_phone";


DatabaseHelper dbHelper;

public static class DatabaseHelper extends SQLiteOpenHelper {

    public DatabaseHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
        // TODO Auto-generated constructor stub
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        // TODO Auto-generated method stub
        db.execSQL("CREATE TABLE " + LOGIN_TABLE_NAME + " (" + KEY_ROWID
                + " INTEGER PRIMARY KEY AUTOINCREMENT, " + A_NAME
                + " TEXT NOT NULL, " + A_PHONE + " TEXT NOT NULL);"
                );
    }

public long insertEntry(String userName,String password)
{
    //SQLiteDatabase db = this.getWritableDatabase();
   ContentValues newValues = new ContentValues();
    // Assign values for each row.
    newValues.put("A_NAME", userName);
    newValues.put("A_PHONE", password);


    // Insert the row into your table
    return ourDatabase.insert(LOGIN_TABLE_NAME, null, newValues);
    //Toast.makeText(context, "Reminder Is Successfully Saved", Toast.LENGTH_LONG).show();

}

}

i try insert to the data following message appears:android.database.sqlite.SQLiteException: table Login has no column named A_NAME (code 1): , while compiling: INSERT INTO Login(A_NAME,A_PHONE) VALUES (?,?)

Aucun commentaire:

Enregistrer un commentaire