`execSQL();`方法不正常工作。我该如何使其生效?

huangapple go评论154阅读模式
英文:

execSQL(); method not working properly. how can i make it work?

问题

我正在尝试创建一张新表,但是一旦我运行应用程序,它就显示一个错误,提示在db.execSQL()中有些问题。

public void onCreate(SQLiteDatabase db) {
    db.execSQL("CREATE TABLE " + TABLE_NAME + "(ID INTEGER PRIMARY KEY AUTOINCREMENT, Username TEXT, Password TEXT)");
}
英文:

I am trying to create a new table but as soon as i run the app it shows me an error that something is not right in the db.execSQL();

public void onCreate(SQLiteDatabase db) {
    db.execSQL("CREATE TABLE "+TABLE_NAME+"(ID INTEGER PRIMARY KEY AUTOINCREMENT, Username TEXT, Password TEXT");
}

答案1

得分: 0

public void onCreate(SQLiteDatabase db) {
    db.execSQL("CREATE TABLE " + TABLE_NAME + "(ID INTEGER PRIMARY KEY AUTOINCREMENT, Username TEXT, Password TEXT)");
}
There is an issue in SQL query statement, I hope it helps you. Thanks
英文:

Update your code :

public void onCreate(SQLiteDatabase db) {
    db.execSQL("CREATE TABLE "+TABLE_NAME+"(ID INTEGER PRIMARY KEY AUTOINCREMENT, Username TEXT, Password TEXT)”);

}

There is an issue in SQL query statement, I hope it helps you. Thanks

huangapple
  • 本文由 发表于 2020年5月31日 04:01:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/62108007.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定