dcsimg
Results 1 to 3 of 3

Thread: How to delete record data from database in listview

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2019
    Posts
    14

    How to delete record data from database in listview

    hi can someone help me how to delete selected data record from database in listview .

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    20,966

    Re: How to delete record data from database in listview

    Each ListItem could have its Tag property assigned the primary key (or some key) of the database row it corresponds to. Use the SelectedItem's Tag to delete the row.

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2019
    Posts
    14

    Re: How to delete record data from database in listview

    Private Sub del_Click()
    confirm = MsgBox("Do you want to delete the Employee Record", vbYesNo + vbCritical, "Deletion Confirmation")
    If confirm = vbYes Then
    Set rs = New ADODB.Recordset
    rs.ActiveConnection = con
    rs.CursorLocation = adUseClient
    rs.CursorType = adOpenDynamic
    rs.LockType = adLockOptimistic
    rs.Source = "SELECT * FROM ATTENDANCE where EMPID= '" & Trim(Listview1.SelectedItem) & "'"
    rs.Open
    If Not rs.EOF Then
    With rs
    'delete data from listview and database
    .Delete adAffectCurrent
    .MoveNext
    End With
    Listview1.ListItems.Clear

    MsgBox "Record successfully deleted..", vbInformation, "Success"

    End If
    loaddata
    End If
    End Sub


    I tried this code but it deleted first item in listview

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width