Android Question Not autoincrement primary key

ivavilagu

Member
Licensed User
Longtime User
I created a DB with the "DB Browser for SQLite" software. At the picture attached you can see two tables with their primary keys fields.

If I insert a new register, the ID primary key field keeps empty

B4X:
SQL1.ExecNonQuery2("INSERT INTO referencia VALUES(null,?,?,?)", Array As Object(txtREFERENCIA.Text, txtMAQUINA.text, txtPUESTO.Text))

For i =0 To lstMOVIMIENTOS.Size - 1
SQL1.ExecNonQuery2("INSERT INTO movimientos VALUES(null,?,?,?)", Array As Object(1,  lstMOVIMIENTOS.GetItem(i), lstTMTP.GetItem(i)))
Next
 

Attachments

  • Captura de pantalla 2015-01-19 a las 10.56.02.png
    Captura de pantalla 2015-01-19 a las 10.56.02.png
    99.9 KB · Views: 504

ivavilagu

Member
Licensed User
Longtime User
Hello,
My first column in all my databases (SQLite, MySQL, MSSQL etc) is called id. In SQLite it would be created as follows, thus the id column will always auto increment.
B4X:
[id] INTEGER  PRIMARY KEY AUTOINCREMENT NOT NULL,

I don´t think it´s a naming problem, but I´m not sure .
 
Upvote 0

ivavilagu

Member
Licensed User
Longtime User
I didn't say that it was. I was just saying that the above line is mandatory in all my databases and it works perfect, so just add AUTOINCREMENT NOT NULL and give it a go :)

Ups, Ok. The problem is that I had created the table with a external software. Is it possible to determine the primary key once the table has been created before?
 
Upvote 0

ivavilagu

Member
Licensed User
Longtime User
Thank you!! you`re agree. In the software there is an autoincrement option, a little bit hidden but it´s works perfectly.

Thank you again man!
 
Upvote 0
Top