SQLiteException:near";"语法错误(代码1):,编译时:INSERT INTO SubjectsDB(' softskill',' no');

时间:2015-11-21 06:59:08

标签: android

boolean DBExist = checkDatabaseExist();
Toast.makeText(this,DBExist + " <- DB Exists :p",Toast.LENGTH_LONG).show();
if(!DBExist){
SQLiteDatabase DB = openOrCreateDatabase(DB_NAME, MODE_PRIVATE, null);
try{
    DB.execSQL("CREATE TABLE IF NOT EXISTS SubjectsDB(name VARCHAR, major VARCHAR);");
    DB.execSQL("INSERT INTO SubjectsDB(\'softskill\',\'no\');");
}catch (Exception e){
    Toast.makeText(this,"Ohh!!"+e.toString(),Toast.LENGTH_LONG).show();
}
Toast.makeText(this,"Data Entered Successfully",Toast.LENGTH_LONG).show();

这是我试图将两个字符串插入数据库的代码,但它以分号显示错误

1 个答案:

答案 0 :(得分:0)

使用以下代码

DB.execSQL("INSERT INTO SubjectsDB values(\'softskill\',\'no\');");