-
Oct 21st, 2019, 11:28 PM
#1
Thread Starter
New Member
How to delete record data from database in listview
hi can someone help me how to delete selected data record from database in listview .
-
Oct 22nd, 2019, 12:47 AM
#2
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.
-
Oct 22nd, 2019, 12:55 AM
#3
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|