Problem with SQLite autoincrement field in Listview

serdar

New Member
Licensed User
Longtime User
Hello and thanks for great app.

I have a simple SQlite table with one autoincrement and one text fields and I populated Listview with table showing only the text fields.

Then I select a row to get Position value to delete or edit text field. But Position Value does not match with actual autoincrement number.

Is there a way to get selected records autoincrement field value in Listview without listing actual autoincrement value itself ?

Serdar,
 

NJDude

Expert
Licensed User
Longtime User
You could save the records from the database to a List, in this case you will save the autoincrement field, so, when the user click on the list view, you use the index of the list view to grab the autoincrement value and retrieve your record from the DB.
 
Last edited:
Upvote 0

Ricky D

Well-Known Member
Licensed User
Longtime User
That's the easiest way to do it

cheers, Ricky
 
Upvote 0

serdar

New Member
Licensed User
Longtime User
Thank you for help it works. But filling Listview and a seperate List takes a long time and memory for long tables with a lot of fields.

I figured that I can extract autointeger KeyValue within Itemclick Sub. Provided that Text value is unique.

Thanks
Serdar,

B4X:
Sub Listview1_ItemClick (Position As Int, Value As Object)
        Dim KeyValue as Int
   KeyValue=SQL1.ExecQuerySingleResult("SELECT AutoInt FROM MyTable WHERE Text='" & Value & "'")
End Sub
 
Upvote 0

flandersdl

Member
Licensed User
Longtime User
Are you using .AddSingleLine2? You could put the auto increment in the ReturnValue and then use it to delete or edit the text.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…