-2
String QUERY11 = "CREATE TABLE " + TABLE_NAME + "(" + COL_DATE + " TEXT, " + COL_FAULT + " TEXT, " + COL_PARTREPLACE + " TEXT, " + COL_AMOUNT + " TEXT, " + COL_TECHNICIAN + " TEXT);";         

when i used this line in my code then it give error like

android.database.sqlite.SQLiteException: near "5151": syntax error (code 1): , while compiling: CREATE TABLE 5151(date TEXT, fault TEXT, partReplace TEXT, amount TEXT, technician TEXT);

Abu Yousuf
  • 5,729
  • 3
  • 31
  • 50

4 Answers4

1

Your TABLE_NAME is an Integer, you should use String

Damir Mailybayev
  • 1,031
  • 1
  • 9
  • 14
0

Table names that are valid without using brackets around them should be any alphanumeric combination that doesn't start with a digit:

Check the accepted answer of this question

Community
  • 1
  • 1
Abu Yousuf
  • 5,729
  • 3
  • 31
  • 50
0

You can't use numeric as first letter of table name, your table name start with a character or you can try this.

String QUERY11 = "CREATE TABLE '" + TABLE_NAME + "'(" + COL_DATE + " TEXT, " + COL_FAULT + " TEXT, " + COL_PARTREPLACE + " TEXT, " + COL_AMOUNT + " TEXT, " + COL_TECHNICIAN + " TEXT);";
Amit Bhati
  • 1,405
  • 12
  • 20
0

Sql Table Name structure:

  • Only Alphanumeric characters and underline are allowed.
  • The field name must begin with an alpha character or underline

    abc123 - valid

    123abc - not valid

    abc_123 - valid

    _123abc - valid

sivaBE35
  • 1,876
  • 18
  • 23