How to retrieve selection in listview??

aldrin_roxas

New member
Joined
Nov 7, 2010
Messages
3
Location
Philippines
Programming Experience
Beginner
I'm currently creating a program using vb and sql codes.. What I want to know is, how can I get the value in my listview so that I can edit/delete it..


Here's my code, I know it's wrong, I'm a newbie..
VB.NET:
 Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim Command As New SqlCommand
        Dim mytablecursor = Cursor
        Command.Connection = Connection
        Command.CommandText = "DELETE FROM Employee WHERE CURRENT OF mytablecursor"
        Connection.Open()
        Dim rows As Integer
        Try
            rows = Command.ExecuteNonQuery()
            If rows = 1 Then
                MsgBox("Employee deleted successfully!")
            ElseIf rows = 0 Then
                MsgBox("No Employee was deleted. It may have already been removed from the Employee table!")
            Else
                MsgBox("Multiple deletions! Please check the database!")
            End If
        Catch ex As Exception
            MsgBox("Failed to remove customer!" & vbCrLf & ex.Message)
        Finally
            Connection.Close()
        End Try
    End Sub
End Class
Hope someone can help.. Thanks!
 
Back
Top