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
This article has been dead for over six months. Start a new discussion instead.