how to delete in lisview base on selected items help pls

this is my sql code for delete

Try
            If identifier = Nothing Then
                MessageBoxEx.EnableGlass = False
                MessageBoxEx.Show("Please Choose an Item to Delete", "Specialized Training", MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation)
            Else
                Select Case MessageBox.Show("Are you sure you want to delete?", "Specialized Training", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)
                    Case DialogResult.Yes
                        ConnectDatabase()
                        Dim SqlQuery As String = "Delete from specializedtraining Where NR='" & lvList.SelectedItems(0).Text & "'"
                        Dim SqlCommand As New MySqlCommand


                        With SqlCommand
                            .CommandText = SqlQuery
                            .Connection = Conn.conn
                            .ExecuteNonQuery()
                        End With
                        LoadRecords()
                        MessageBoxEx.EnableGlass = False
                        MessageBoxEx.Show("Item Successfully Deleted", "Specialized Training", MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information)
                        SqlCommand.Dispose()
                        DisconnectDatabase()


                End Select
            End If
            Try
            Catch ex As MySqlException
                MsgBox(ex.Message, MsgBoxStyle.Critical)
            End Try
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical)
        End Try
        identifier = Nothing

Perhaps if you asked a clearer question and told us what your code is supposed to do we might be able to help.

how to delete multi items in listview?

For Each item As ListViewItem In ListView1.SelectedItems
    item.Remove()
Next
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.