“”附近:SQL 和 android studio 中的语法错误
near "": syntax error in SQL with android studio
我正在 java(android 工作室项目)的 SQL 数据库上工作,但我有一个奇怪的错误。
基本上,每次我有
near "Hello": syntax error in "INSERT INTO GAMES(_id, PRICE, NAME, DEV, PLATFORM) VALUES (0, 70, Hello, Henri, Terrain)"
我试过这样
public void addGame(String Price, String Name, String Dev, String Platform) {
database = getWritableDatabase();
database.execSQL("INSERT INTO "+ SchemeDB.TAB_GAMES +"("
+ DBS.COL_GAMES_ID +", "
+ DBS.COL_GAMES_PRICE +", "
+ DBS.COL_GAMES_NAME +", "
+ DBS.COL_GAMES_DEV +", "
+ DBS.COL_GAMES_PLATFORM +") VALUES (" + i +", "
+ Price +", "
+ Name +", "
+ Dev +", "
+ Platform +")");
database.close();
}
我的 DBS 是
public interface SchemeDB {
int VERSION = 1;
String DB_NAME = "????";
String TAB_GAMES = "???";
String COL_GAMES_ID = "_id";
String COL_GAMES_PRICE = "PRICE";
String COL_GAMES_NAME = "NAME";
String COL_GAMES_DEV = "DEV";
String COL_GAMES_PLATFORM = "PLATFORM";
}
而且我真的看不出哪里错了。因为他们说的是“语法错误”,但对我来说,它看起来还不错。
有人有线索吗?我只是想在我的数据库中插入一些东西。
像这样...
+ "'" + Name + "', "
+ "'" + Dev + "', "
+ "'" + Platform + "')");
我正在 java(android 工作室项目)的 SQL 数据库上工作,但我有一个奇怪的错误。 基本上,每次我有
near "Hello": syntax error in "INSERT INTO GAMES(_id, PRICE, NAME, DEV, PLATFORM) VALUES (0, 70, Hello, Henri, Terrain)"
我试过这样
public void addGame(String Price, String Name, String Dev, String Platform) {
database = getWritableDatabase();
database.execSQL("INSERT INTO "+ SchemeDB.TAB_GAMES +"("
+ DBS.COL_GAMES_ID +", "
+ DBS.COL_GAMES_PRICE +", "
+ DBS.COL_GAMES_NAME +", "
+ DBS.COL_GAMES_DEV +", "
+ DBS.COL_GAMES_PLATFORM +") VALUES (" + i +", "
+ Price +", "
+ Name +", "
+ Dev +", "
+ Platform +")");
database.close();
}
我的 DBS 是
public interface SchemeDB {
int VERSION = 1;
String DB_NAME = "????";
String TAB_GAMES = "???";
String COL_GAMES_ID = "_id";
String COL_GAMES_PRICE = "PRICE";
String COL_GAMES_NAME = "NAME";
String COL_GAMES_DEV = "DEV";
String COL_GAMES_PLATFORM = "PLATFORM";
}
而且我真的看不出哪里错了。因为他们说的是“语法错误”,但对我来说,它看起来还不错。 有人有线索吗?我只是想在我的数据库中插入一些东西。
像这样...
+ "'" + Name + "', "
+ "'" + Dev + "', "
+ "'" + Platform + "')");