[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
            .Update()
        End With
BROOKLYN1950Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jim Dettman (Microsoft MVP/ EE MVE)President / OwnerCommented:
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.

Jim.
0
AccessGuy1763Commented:
Maybe I'm way off here, but isn't a call to Edit() required before you change the field values and do the Update()?
0
Jeffrey CoachmanMIS LiasonCommented:
@AccessGuy1763,
I though that too,
;-)
...but it looks like ADO code, so .edit is not needed....
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Jeffrey CoachmanMIS LiasonCommented:
BROOKLYN1950,

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
    .Open
    .MoveFirst
    .Fields("FirstName").Value = "John"
    .Fields("LastName").Value = "Smith"
    .Update
End With

Set rec = Nothing
Set cnn = Nothing


JeffCoachman
0
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.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BROOKLYN1950Author Commented:
I figured out the problem myself
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.