how to solve insert with Null?
database with two tables
1) Group (idGroup integer, Group_Name text)
2) students (idStudent INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE, Name_of_Student text, idgroup integer)
idgroup is a FOREIGN KEY references Gruoup / idGroup
database with two tables
1) Group (idGroup integer, Group_Name text)
2) students (idStudent INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE, Name_of_Student text, idgroup integer)
idgroup is a FOREIGN KEY references Gruoup / idGroup
B4X:
Dim name As TextField
name.Initialize("")
name.Text="albert einstein"
'
Dim group As TextField
group.Inizialize("")
group.text = null ' how to set Null ???
'
sql.ExecNonQuery("PRAGMA foreign_keys = ON")
'next code is bad
sql.ExecNonQuery2("insert into students values (?, ?)", Array As Object( name.Text, group.Text)) 'Abort due to constraint violation (foreign key constraint failed)
'
'this is ok
sql.ExecNonQuery2("insert into students values (?, ?)", Array As Object(name.Text, Null)) ' this is ok! but I don't want to write null
'
'this code is OK!
name.Text="Alessandro Volta"
gruppi.text = "1" 'this is a id of table named group (id 1 is exists!)
sql.ExecNonQuery2("insert into students values (?, ?)", Array As Object(name.Text, gruppi.Text)) 'success