fifiddu70 Well-Known Member Licensed User Longtime User Oct 8, 2019 #1 hello, i use sqlite for populate spinner for my project, i need to update the element stored in database, for populate i use this code: Code: dbSQL.ExecNonQuery2("INSERT INTO field9 VALUES (?)", Array As String(txtmenu.Text & " - " & "Euro" & " " & txtcaricoeuro.Text)) spmn9.Add (txtmenu.Text & " " & "Euro" & " " & txtcaricoeuro.Text) txtcaricoeuro.Text="" dbCursor.Close txtmenu.Text="" example in txtmenu i write: Spaghetti and txtcaricoeuro i write: 6.00 with spmn9.add i added: spaghetti - Euro 6.00 with thi code i load the spinner with all data stored: Code: Sub mn9 spmn9.Clear dbCursor = dbSQL.ExecQuery("SELECT * FROM field9") For I = 0 To dbCursor.RowCount - 1 dbCursor.Position = I spmn9.Add(dbCursor.GetString("data9")) Next dbCursor.Close End Sub Now i need to modify one element loaded in this spinner. example: Spaghetti - euro 6.00 updated with Spaghetti - Euro 7.50 what code should i use to modify this element? for delete element i use: Code: dbSQL.ExecNonQuery2("DELETE FROM field9 WHERE data9 = ?", Array As String(spmn9.SelectedItem)) for update or modify this element without delete?
hello, i use sqlite for populate spinner for my project, i need to update the element stored in database, for populate i use this code: Code: dbSQL.ExecNonQuery2("INSERT INTO field9 VALUES (?)", Array As String(txtmenu.Text & " - " & "Euro" & " " & txtcaricoeuro.Text)) spmn9.Add (txtmenu.Text & " " & "Euro" & " " & txtcaricoeuro.Text) txtcaricoeuro.Text="" dbCursor.Close txtmenu.Text="" example in txtmenu i write: Spaghetti and txtcaricoeuro i write: 6.00 with spmn9.add i added: spaghetti - Euro 6.00 with thi code i load the spinner with all data stored: Code: Sub mn9 spmn9.Clear dbCursor = dbSQL.ExecQuery("SELECT * FROM field9") For I = 0 To dbCursor.RowCount - 1 dbCursor.Position = I spmn9.Add(dbCursor.GetString("data9")) Next dbCursor.Close End Sub Now i need to modify one element loaded in this spinner. example: Spaghetti - euro 6.00 updated with Spaghetti - Euro 7.50 what code should i use to modify this element? for delete element i use: Code: dbSQL.ExecNonQuery2("DELETE FROM field9 WHERE data9 = ?", Array As String(spmn9.SelectedItem)) for update or modify this element without delete?
Erel B4X founder Staff member Licensed User Longtime User Oct 8, 2019 #2 Looks a bit strange that you are not using two columns. One for the product and one for the price. Code: dbSQL.ExecNonQuery2("UPDATE field9 SET data9 = ? WHERE data9 = ?", Array As String("Spaghetti - Euro 7.50",spmn9.SelectedItem)) Upvote 0
Looks a bit strange that you are not using two columns. One for the product and one for the price. Code: dbSQL.ExecNonQuery2("UPDATE field9 SET data9 = ? WHERE data9 = ?", Array As String("Spaghetti - Euro 7.50",spmn9.SelectedItem))
fifiddu70 Well-Known Member Licensed User Longtime User Oct 8, 2019 #3 Erel it's an old method I learned from a member and I've always worked like that. anyway thanks for your advice. Upvote 0
Erel it's an old method I learned from a member and I've always worked like that. anyway thanks for your advice.
fifiddu70 Well-Known Member Licensed User Longtime User Oct 8, 2019 #4 Erel said: Looks a bit strange that you are not using two columns. One for the product and one for the price. Code: dbSQL.ExecNonQuery2("UPDATE field9 SET data9 = ? WHERE data9 = ?", Array As String("Spaghetti - Euro 7.50",spmn9.SelectedItem)) Click to expand... Erel, excuse me, but now there is another problem, there are 9 spinner renamed as: spmn1 - spmn2 - etc. so how do I update an item in one of these spinners? Upvote 0
Erel said: Looks a bit strange that you are not using two columns. One for the product and one for the price. Code: dbSQL.ExecNonQuery2("UPDATE field9 SET data9 = ? WHERE data9 = ?", Array As String("Spaghetti - Euro 7.50",spmn9.SelectedItem)) Click to expand... Erel, excuse me, but now there is another problem, there are 9 spinner renamed as: spmn1 - spmn2 - etc. so how do I update an item in one of these spinners?
Erel B4X founder Staff member Licensed User Longtime User Oct 10, 2019 #5 Store the spinner items in Lists. You can use a Map that maps between the spinners and their lists. Update the relevant list and then call Spinner.Clear and Spinner.AddAll with the list. Upvote 0
Store the spinner items in Lists. You can use a Map that maps between the spinners and their lists. Update the relevant list and then call Spinner.Clear and Spinner.AddAll with the list.