this is the code im using:
Dim ds As New DataSet For Each row As DataGridViewRow In dgvSearch2.Rows If row.Cells("Check").Selected = True Then con.Open() com.CommandText = "Select Password from login where Username = '" & MainFrm.lblLMCon.Text & "' and AccountType = 'Administrator';" com.Connection = con c = com.ExecuteReader If c.Read = True Then Dim delete As String Dim where As String delete = InputBox("Enter administator password:") where = InStr(c.Item("Password").ToString, delete) If where Then da = New OleDbDataAdapter("Delete * from list where ID = '" & dgvSearch2.CurrentRow.Cells("ID").Value & "'", con) da.Fill(ds) dgvSearch2.Rows.Remove(row) Else MsgBox("Invalid Password. Try Again!") End If Else MsgBox("Nothing to delete") End If con.Close() End If Next
though this code gave no error, my problem is that it only deletes one row upon button click. for example i checked two checkbox in the datagridview(which must represent the whole row) but only one of this is deleted.
i want to delete it in the database and not only in the dgv. can someone help me pinpoint what is wrong with the code?