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.
[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.