0

我的数据库中有这张表

  public static final String TABLE_MOVIES_NAME = "MyMovies";
  public static final String TABLE_MOVIES_COLUMN_ID = "_Id";
  public static final String TABLE_MOVIES_COLUMN_NAME = "_Name";
  public static final String TABLE_MOVIES_COLUMN_DATE_ADDED = "_AddedDate";
  public static final String TABLE_MOVIES_COLUMN_DATE_RELEASE = "_ReleaseDate";
  public static final String TABLE_MOVIES_COLUMN_DESCRIPTION = "_Description";

  private static final String DATABASE_NAME = "????.db";
  private static final int DATABASE_VERSION = 1;

  public static final String DATABASE_CREATE = "create table "
      + TABLE_MOVIES_NAME + "("
      + TABLE_MOVIES_COLUMN_DATE_RELEASE + "text not null, "
      + TABLE_MOVIES_COLUMN_ID + " integer primary key, "
      + TABLE_MOVIES_COLUMN_NAME + " text not null, "
      + TABLE_MOVIES_COLUMN_DATE_ADDED + " text not null, "
      + TABLE_MOVIES_COLUMN_DESCRIPTION + " text not null);";

我尝试在其中添加一些值(电影)ContentValues values = _ReleaseDate=2013-06-18 _Id=0 _Name=a _AddedDate=2013-02-18 _Description=asfsgagafgadf

当我插入时database.insertOrThrow(SQLiteHelper.TABLE_MOVIES_NAME, null, values);
我得到这个错误android.database.sqlite.SQLiteException: table MyMovies has no column named _ReleaseDate (code 1): , while compiling: INSERT INTO MyMovies(_ReleaseDate,_Id,_Name,_AddedDate,_Description) VALUES (?,?,?,?,?) 我做错了什么?

4

2 回答 2

2

改变:

public static final String DATABASE_CREATE = "create table "
      + TABLE_MOVIES_NAME + "("
      + TABLE_MOVIES_COLUMN_DATE_RELEASE + "text not null, "
      + TABLE_MOVIES_COLUMN_ID + " integer primary key, "
      + TABLE_MOVIES_COLUMN_NAME + " text not null, "
      + TABLE_MOVIES_COLUMN_DATE_ADDED + " text not null, "
      + TABLE_MOVIES_COLUMN_DESCRIPTION + " text not null);";

到:

public static final String DATABASE_CREATE = "create table "
      + TABLE_MOVIES_NAME + "("
      + TABLE_MOVIES_COLUMN_DATE_RELEASE + " text not null, "//Space added here.
      + TABLE_MOVIES_COLUMN_ID + " integer primary key, "
      + TABLE_MOVIES_COLUMN_NAME + " text not null, "
      + TABLE_MOVIES_COLUMN_DATE_ADDED + " text not null, "
      + TABLE_MOVIES_COLUMN_DESCRIPTION + " text not null);";
于 2013-02-19T21:53:54.457 回答
0

在此处添加空格:

  + TABLE_MOVIES_COLUMN_DATE_RELEASE + " text not null, "  // space before 'text'
于 2013-02-19T21:55:04.847 回答