Question Updating database

ETCallHome

Member
Joined
Apr 1, 2014
Messages
5
Programming Experience
10+
Hi,

I get the following error when trying to update my Dataset, i.e. I am trying to update an Access Database from VB.Net:

OLEDBException was handled
Operation must use an updateable query

Here is the code I am using

Private Sub Update_Click(......) Handles Update.Click
Dim cb as New OleDb.OleDbCommandBuilder(da) ... "da" declared as da As New OleDb.OleDbDataAdapter

ds.Tables("TblName").Rows(x)Items(y) = txtSomething.Text

da.Update(ds, "TblName")
MsgBox("Record Updated")
End Sub

Please bear in mind that all the other connections, i.e. connection object, connection string, etc are all working fine. And I can successfully open and close the connection and retrieve the information. It is only when I am trying to change something in one of the records, and then updating that I get this error. If I do not change anything and just press update, then I get the "Record Updated" message.

Thanks a mill for any assistance.

ETCallHome from SA:sour:
 
That seems an odd error message under the circumstances. Try calling the methods to get the generated commands from the command builder, e.g. GetUpdateCommand, and examine the CommandText of the command object to see if it makes sense.
 
Hi Everyone,

After searching the internet for answer... and there were many who had similar problems with no actual answers. I then went to open the access database and moved it into a trusted location where I have update rights, was read-only. Then run my code and the database was updated. In other words when you get this type of error when all the code is exactly what it should be, check if the database is read-only or not, if ready-only then you need to make it updateable before you can use the OLEDB.OLEDBCOMMANDBUILDER... Nothing wrong with my code.

Thanks
 
Hi,

I am trying to close this thread as resolved, but I cannot figure out how to set the status of the thread to resolve.

Thanks
ETCallHome
:chuncky:
 
Back
Top