Android Question How to use DBUtils.DeleteRecord(Starter.SQL1,"Students", !?)

Theera

Well-Known Member
Licensed User
Longtime User
In The first activity,I have success for map data as code belows
Dim ListOfMaps As List
ListOfMaps.Initialize
For i = 1 To 40
Dim m As Map
m.Initialize
m.Put("Id", Id)
m.Put("First Name", "John")
m.Put("Last Name", "Smith" & i)
ListOfMaps.Add(m)
Next
DBUtils.InsertMaps(Starter.SQL1, "Students", ListOfMaps)

and another activity,I use webview to show database
WebView1.LoadHtml(DBUtils.ExecuteHtml(Starter.SQL1,"SELECT [Id],[First Name] || ' ' || [Last Name] As Name From "Students",Null,0,True))

Now,I need to delete the record from WebView1 after I click and get the row ,I can't set the map in the command and update webview
DBUtils.DeleteRecord(Starter.SQL1,"Students", !?)

I'm sorry my English.
 

Theera

Well-Known Member
Licensed User
Longtime User
It should be:

B4X:
DBUtils.DeleteRecord(Starter.SQL1, "Students", CreateMap("Id":HereTheIdYouSeleted))
It 's correct only the first time's deletion ,and then I need to delete the record again ,the row is not equal to ID. How do I get ID from the row which is selected?
 
Upvote 0

Theera

Well-Known Member
Licensed User
Longtime User
Ok My problrem is solved myself. Thank you for kind of you,LucaMs
row= values(1)
'Delete Record which is selected
ToastMessageShow(row,False)
Dim Csr As Cursor
Csr = SQL1.ExecQuery("SELECT ID FROM Students")
Csr.Position = row
ToastMessageShow("Cursor=" &Csr.GetInt("ID") ,False)
DBUtils.DeleteRecord(SQL1,"Students", CreateMap("ID":Csr.GetInt("ID") ))
 
Last edited:
Upvote 0
Top