Hello rjoubert
I still could find what to do with this error. below is my peice of code for the deletion of specific record. this code tries to delete all rows with 'Month' field value of January. Please help:
-----------------------------
Try
If Not (Me.cmbMonth.Text = "") Then
Dim msg As String
Dim title As String
Dim style As MsgBoxStyle
Dim response As MsgBoxResult
PayMonth = Me.cmbMonth.Text
msg = "This will delete any record for this month and create new data. Do you want to continue?" ' Define message.
style = MsgBoxStyle.DefaultButton2 Or _
MsgBoxStyle.Critical Or MsgBoxStyle.YesNo
title = "Payroll Manager" ' Define title.
' Display message.
response = MsgBox(msg, style, title)
If response = MsgBoxResult.Yes Then ' User chose Yes.
' Perform some action.
Dim objDataTable As DataTable
Dim objDataRows As DataRow()
Dim objDataRow As DataRow
objDataTable = EmpPayroll1.Tables("dbo_Payroll")
objDataRows = objDataTable.Select("Month='January'")
For Each objDataRow In objDataRows
objDataRow.Delete()
Next
Me.OleDbDataAdapter2.Update(EmpPayroll1, "dbo_Payroll")
Else
' Perform some other action.
End If
Else
MsgBox("Please choose a month for Payroll Data creation", MsgBoxStyle.Exclamation, "Payroll Manager")
Exit Sub
End If
Catch ex As Exception
Throw ex
End Try
----------------
what is wrong with this? or what should i do?
thanks