M masterleous Member Licensed User Longtime User Mar 20, 2013 #1 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. Code: Copy 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 Code: Copy 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 Code: Copy 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: Mar 20, 2013
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. Code: Copy 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 Code: Copy 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 Code: Copy 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?
M Malky Active Member Licensed User Longtime User Mar 20, 2013 #2 Where is the loop? For i = 1 to 5? You seem to be creating one row? Could you maybe add the edit.texts to an array beforehand and use the same loop? Sorry if I'm off course on this, only trying to help. I've never tried a concat on a variable name as in EditText & i.text in B4A which would seem ideal? Malky Upvote 0
Where is the loop? For i = 1 to 5? You seem to be creating one row? Could you maybe add the edit.texts to an array beforehand and use the same loop? Sorry if I'm off course on this, only trying to help. I've never tried a concat on a variable name as in EditText & i.text in B4A which would seem ideal? Malky
M masterleous Member Licensed User Longtime User Mar 20, 2013 #3 Thanks Malky for your reply Malky said: Where is the loop? For i = 1 to 5? You seem to be creating one row? Click to expand... Loop was miss typed, it is FillFirstData function in which i am adding 5 different rows of 5 column data. I've never tried a concat on a variable name as in EditText & i.text in B4A which would seem ideal? Click to expand... I am Using Concat as EDITTEXT.Text =, for displaying field text value. Could you maybe add the edit.texts to an array beforehand and use the same loop? Click to expand... not understand your question, please specify Upvote 0
Thanks Malky for your reply Malky said: Where is the loop? For i = 1 to 5? You seem to be creating one row? Click to expand... Loop was miss typed, it is FillFirstData function in which i am adding 5 different rows of 5 column data. I've never tried a concat on a variable name as in EditText & i.text in B4A which would seem ideal? Click to expand... I am Using Concat as EDITTEXT.Text =, for displaying field text value. Could you maybe add the edit.texts to an array beforehand and use the same loop? Click to expand... not understand your question, please specify
M Malky Active Member Licensed User Longtime User Mar 20, 2013 #4 Sorry for the confusion, I don't know if the concat thing would work (except maybe in my head)? I am a newbie, but will try what I know. Create an array and add the texts from each edittext The use your loop (for i = 1 to 5) to step through the array and use the same code you have in the first code posted to add the data in the maps? Malky Upvote 0
Sorry for the confusion, I don't know if the concat thing would work (except maybe in my head)? I am a newbie, but will try what I know. Create an array and add the texts from each edittext The use your loop (for i = 1 to 5) to step through the array and use the same code you have in the first code posted to add the data in the maps? Malky
M masterleous Member Licensed User Longtime User Mar 21, 2013 #5 Malky said: Create an array and add the texts from each edittext The use your loop (for i = 1 to 5) to step through the array and use the same code you have in the first code posted to add the data in the maps? Click to expand... I shall try it today, and let you know Upvote 0
Malky said: Create an array and add the texts from each edittext The use your loop (for i = 1 to 5) to step through the array and use the same code you have in the first code posted to add the data in the maps? Click to expand... I shall try it today, and let you know
M masterleous Member Licensed User Longtime User Mar 25, 2013 #6 Thanks Malky for your help, Problem has been solved now, i was doing mistake in initializing of EditText fields, i was doing wrong. Now it is cleared by initializing EditText like as; Code: Copy EditText1.Initialize("EditText1") before it was i was doing mistake like as Code: Copy EditText1.Initialize("EditText") which was incorrect format. Thanks Upvote 0
Thanks Malky for your help, Problem has been solved now, i was doing mistake in initializing of EditText fields, i was doing wrong. Now it is cleared by initializing EditText like as; Code: Copy EditText1.Initialize("EditText1") before it was i was doing mistake like as Code: Copy EditText1.Initialize("EditText") which was incorrect format. Thanks