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 に答える