Hi,
I am using 5 EditText fields in Designer window and has declared in Process global. I am trying to store all these EditText data in SQL, for which i had made one Save Button. I am using DBUilt example as a reference. The problem is that when ever i use auto fill data using FillFirstData function for stroing in SQL, its goes fine, but whenever i tried to store custom data by typing in above five Edittext field, i got error.
Above code stores 5 different data to sql table, and i can view that.
But following code gives error
Above Code Gives Error
I had tried to view EditText fields with LOGcat, and realized that only first EditText gets the value, other has no value
What i am doing wrong?
I am using 5 EditText fields in Designer window and has declared in Process global. I am trying to store all these EditText data in SQL, for which i had made one Save Button. I am using DBUilt example as a reference. The problem is that when ever i use auto fill data using FillFirstData function for stroing in SQL, its goes fine, but whenever i tried to store custom data by typing in above five Edittext field, i got error.
B4X:
Sub FillFirstData
Dim ListOfMaps As List
ListOfMaps.Initialize
Dim id As Int
For i = 1 To 5
Dim m As Map
m.Initialize
m.Put("Data1", "ABC" & i)
m.Put("Data2", "DEF" & i)
m.Put("Data3", "GHI" & i)
m.Put("Data4", "MNO" & i)
m.Put("Data5", "PQR" & i)
ListOfMaps.Add(m)
Next
DBUtils.InsertMaps(SQL, "Datatable", ListOfMaps)
End Sub
Above code stores 5 different data to sql table, and i can view that.
But following code gives error
B4X:
Sub btSave_Click
Dim ListOfMaps As List
ListOfMaps.Initialize
Dim m As Map
m.Initialize
m.Put("Data1", EditText1.Text)
m.Put("Data2", EditText2.Text)
m.Put("Data3", EditText3.Text)
m.Put("Data4", EditText4.Text)
m.Put("Data5", EditText5.Text)
ListOfMaps.Add(m)
Next
DBUtils.InsertMaps(SQL, "Datatable", ListOfMaps)
End Sub
Above Code Gives Error
B4X:
InsertMaps (first query out of 2): INSERT INTO [Datatable] ([Data1], [Data2], [Data3], [Data4], [Data5]) VALUES (?, ?, ?, ?, ?, ?)
(SQLiteConstraintException) android.database.sqlite.SQLiteConstraintException: error code 19: constraint failed
I had tried to view EditText fields with LOGcat, and realized that only first EditText gets the value, other has no value
What i am doing wrong?
Last edited: