我有错误:
while compiling: CREATE_TABELLOGIN(IDINTEGER PRIMARY KEY AUTOINCREMENT,USERNAME text,PASSWORD text)
DATABASES CLASS:
public class LoginDataBaseAdapter {
static final String DATABASE_NAME="login.db";
static final int DATABASE_VERSION=1;
public static final int NAME_COLUMN=1;
static final String DATABASE_CREATE= "CREATE_TABEL" + "LOGIN" +
"(" + "ID" + "INTEGER PRIMARY KEY AUTOINCREMENT," + "USERNAME text,PASSWORD text);";
答案 0 :(得分:6)
这不是有效的SQL。
您可能认为CREATE TABLE LOGIN
不是CREATE_TABELLOGIN
而ID INTEGER
不是IDINTEGER
。
答案 1 :(得分:0)
答案 2 :(得分:0)
您的DATABASES CLASS:
public class LoginDataBaseAdapter {
static final String DATABASE_NAME="login.db";
static final String DATATABLE_NAME ="LOGIN";
static final int DATABASE_VERSION=1;
public static final int NAME_COLUMN=1;
static final String DATABASE_CREATE= "CREATE TABLE " + DATATABLE_NAME +
" (" + "ID" + " INTEGER PRIMARY KEY AUTOINCREMENT, " + "USERNAME TEXT, PASSWORD TEXT);";
这是您正确的答案检查并运行它。
答案 3 :(得分:0)
是的,查询中的间距存在问题。
static final String DATABASE_CREATE =“CREATE TABEL”+“LOGIN”+ “(”+“ID”+“INTEGER PRIMARY KEY AUTOINCREMENT,”+“USERNAME text,PASSWORD text);”;
尝试打印查询。
是
CREATE TABEL LOGIN(IDINTEGER PRIMARY KEY AUTOINCREMENT,USERNAME text,PASSWORD text);
现在是
CREATE TABEL LOGIN ( ID INTEGER PRIMARY KEY AUTOINCREMENT, USERNAME text, PASSWORD text);
答案 4 :(得分:-1)
public class LoginDataBaseAdapter {
static final String DATABASE_NAME="login.db";static final int DATABASE_VERSION=1;
public static final int NAME_COLUMN=1;
static final String DATABASE_CREATE= "CREATE TABLE " + "LOGIN" +
"(" + "ID" + " INTEGER PRIMARY KEY AUTOINCREMENT," + " USERNAME text, PASSWORD text);";
你需要在单词之间添加空格,你拼写 TABLE 是错误的。
答案 5 :(得分:-2)
您忘记在"INTEGER
之前留出空格并删除_
CREATE_TABLE
(下划线)
添加如下空格
static final String DATABASE_CREATE= "CREATE TABLE" + "LOGIN" +
"(" + "ID" + " INTEGER PRIMARY KEY AUTOINCREMENT," +
"USERNAME text,PASSWORD text);";