Hi, I have the following code...
This attempts to insert a row into a DB table. However I am getting a unhandled exception of type 'System.InvalidOperationException'. It says that 'Update requires a valid InsertCommand when passed DataRow collection with new rows'
Can anyone please tell me how I can sort this out?
Thanks.
VB.NET:
Sub AddRentalRes(ByVal CopyID As Integer, ByVal DateOut As Date, ByVal DateDue As Date, ByVal MemberID As Integer)
Dim RentalResRow As DataRow
FindMember(MemberID)
RentalResRow = myDS.Tables("LoanRes").NewRow
RentalResRow("CustomerID") = MemberID
RentalResRow("CopyID") = CopyID
RentalResRow("DateOut") = DateOut
RentalResRow("DateDue") = DateDue
Try
myDS.Tables("LoanRes").Rows.Add(RentalResRow)
Catch e As System.Data.ConstraintException
MsgBox("Incorrect data entry", vbExclamation, "Polysoft Media")
Exit Sub
End Try
Try
myAdapter.Update(myDS, "LoanRes")
Catch e As System.Data.OleDb.OleDbException
MsgBox("There was an error during entry", vbExclamation, "Polysoft Media")
Exit Sub
End Try
End Sub
Can anyone please tell me how I can sort this out?
Thanks.