I have a small application which has a MS Access as backend, and the front end is developed using VB.Net 2008. When I click on the listview item and then click delete button to delete a particula list and its content on the database, it is giving me the error as "No value given for one or more required parameters". Please check my code below and help. FYI - My access database have a Primary key as the first character of the firstname combined with the first 2 characters of the lastname. It does not have a Anutonumber fiels. My code for the delete button is as follows: the code was working fine on a MS Access that has a Primary Key as the AutoNumber being generated. Thanking you in advance.
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click If lvData.SelectedIndices.Count <= 0 Then Return 'No selected Item so exit End If Dim ItemNo As Integer = lvData.SelectedIndices(0) 'Grab the selected index Try Dim I As Integer = MsgBox("Are you sure you want to delete this record? You can't Undo", MsgBoxStyle.YesNo, "Are you sure?") If I = MsgBoxResult.Yes Then conn.Open() Dim cmd2 As New OleDb.OleDbCommand("DELETE FROM tblPNGATSAExecutive WHERE ExecutiveID = " & lvData.Items(ItemNo).SubItems(0).Text, conn) cmd2.ExecuteNonQuery() MsgBox("Record removed successfully", MsgBoxStyle.OkOnly, "Remove Succeeded") Else 'They didn't really want to delete, so exit Return 'This exits the sub End If Catch ex As Exception MsgBox(ex.Message) Finally conn.Close() End Try RefreshLV() End Sub