# Selectindex refresh - SQLlite

**URL:** <https://forum.kirupa.com/t/selectindex-refresh-sqllite/287645>\
**Category:** programming\
**Created:** [May 4, 2009, 5:46pm UTC](https://forum.kirupa.com/t/selectindex-refresh-sqllite/287645 "2009-05-04T17:46:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bomber686](https://avatars.discourse-cdn.com/v4/letter/b/b77776/32.png) [@Bomber686](https://forum.kirupa.com/u/Bomber686)\
**Post date:** [May 4, 2009, 5:46pm UTC](https://forum.kirupa.com/t/selectindex-refresh-sqllite/287645/1 "2009-05-04T17:46:04Z")

</div>

Hi,

I have a listbox and I’ve changed it to sorted for ease of use. The listbox gathers information from an SQLlite Database. I am trying to delete items from that database but because I sort the list the selectindex value doesn’t collerate to the ID of the record.

```auto

[SIZE=2]frmPlayers.lstPlayers.Sorted = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]False[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]'MsgBox(frmPlayers.lstPlayers.SelectedIndex)[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SQLconnect [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SQLite.SQLiteConnection()[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SQLcommand [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] SQLiteCommand[/SIZE]
[SIZE=2]SQLconnect.ConnectionString = [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Data Source="[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] & dbGolf & [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]";"[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]SQLconnect.Open()[/SIZE]
[SIZE=2]SQLcommand = SQLconnect.CreateCommand[/SIZE]
[SIZE=2]SQLcommand.CommandText = [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"DELETE FROM par WHERE id = '"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] & frmPlayers.lstPlayers.SelectedIndex + 1 & [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"';"[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]SQLcommand.ExecuteNonQuery()[/SIZE]
[SIZE=2]SQLcommand.Dispose()[/SIZE]
[SIZE=2]SQLconnect.Close()[/SIZE]
[SIZE=2]frmPlayers.lstPlayers.Sorted = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]frmPlayers.Close()[/SIZE]
[SIZE=2]frmPlayers.Show()[/SIZE]

```

So I was looking for a way to refresh the index values once the sorted value is changed to false. I could get the sqlreader.read to gather the ID but I’m not sure how I could do that.
