Alright, I am having the hardest time figuring this out. I have done research on fixing this for a couple days and I am stuck. It is time to ask for help.
In my project I am trying to delete a row out of the database and I read how to do that from many different sources telling me to use Ole objects and all that. I have something that works in a way: the row deletes, but when I run the program it doesn't save when I do it this way.
Public Function ForceDelete()
ForceDelete = Nothing
' Validate
frmDatabase.Validate()
' Make sure no more edits can be made
frmDatabase.bsMagicCards.EndEdit()
' Delete Entry
frmDatabase.RDPCD_CardsDataSet.Tables("tblMagicCards").Rows(frmDatabase.dgCardList.CurrentRow.Index).Delete()
' Accept changes
frmDatabase.RDPCD_CardsDataSet.Tables("tblMagicCards").AcceptChanges()
' Update the table
frmDatabase.TblMagicCardsTableAdapter.Update(frmDatabase.RDPCD_CardsDataSet.tblMagicCards)
' Accept any changes
frmDatabase.RDPCD_CardsDataSet.Tables("tblMagicCards").AcceptChanges()
' Turn off edits
blnEdits = False
DisableAll()
End Function
I know that when it is done this way, the changes are accepted before the update and therefor it won't save it into the database that way, but when I do it this way:
Public Function ForceDelete()
ForceDelete = Nothing
' Validate
frmDatabase.Validate()
' Make sure no more edits can be made
frmDatabase.bsMagicCards.EndEdit()
' Delete Entry
frmDatabase.RDPCD_CardsDataSet.Tables("tblMagicCards").Rows(frmDatabase.dgCardList.CurrentRow.Index).Delete()
' Update the table
frmDatabase.TblMagicCardsTableAdapter.Update(frmDatabase.RDPCD_CardsDataSet.tblMagicCards)
' Accept any changes
frmDatabase.RDPCD_CardsDataSet.Tables("tblMagicCards").AcceptChanges()
' Turn off edits
blnEdits = False
DisableAll()
End Function
Then I get this error:
OleDbException was unhandled
Data type mismatch in criteria expression.
So, I would appreciate any help I can get on this! Thanks in advance!