• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1064
  • Last Modified:

[Microsoft][ODBC Microsoft Access Driver] Cannot update. Database or object is read-only.

I am trying to update a few fields from the following code and get the above error.  I am the only person accessing the database.  Using access 2007 and visual studio 2012

   rec.Open(strsql, cn, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic)

        With rec
            .Fields("Sdate").Value = Sdate
            .Fields("timeVal").Value = Time
            .Fields("notes").Value = notes
            .Fields("overtime").Value = Overtime
        End With
1 Solution
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
Make sure you have full privs for the directory where the DB resides (read, write, and delete).   You should see an .LDB file created when you connect to it.

Maybe I'm way off here, but isn't a call to Edit() required before you change the field values and do the Update()?
Jeffrey CoachmanMIS LiasonCommented:
I though that too,
...but it looks like ADO code, so .edit is not needed....
Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

Jeffrey CoachmanMIS LiasonCommented:

Can you post the entire code?

Code similar to this works fine for me...

Dim cnn As ADODB.Connection
Dim rec As ADODB.Recordset

Set cnn = CurrentProject.AccessConnection

Set rec = New ADODB.Recordset
With rec
    Set .ActiveConnection = cnn
    .Source = "table1"
    .LockType = adLockOptimistic
    .CursorType = adOpenKeyset
    .Fields("FirstName").Value = "John"
    .Fields("LastName").Value = "Smith"
End With

Set rec = Nothing
Set cnn = Nothing

BROOKLYN1950Author Commented:
I figured it out. I was using the WHERE statement to join two tables instead of using an actual JOIN statement. Once I started to use JOIN instead everything worked.
BROOKLYN1950Author Commented:
I figured out the problem myself
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now