0

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
2
Contributors
3
Replies
29
Views
3 Years
Discussion Span
Last Post by Reverend Jim
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.