Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

msaccess sqlserver and cannot update recordset due to lock violation

Posted on 2008-06-25
4
Medium Priority
?
403 Views
Last Modified: 2012-05-05
hI have a msaccess project hooked up to sqlserver and I am trying to update a record set
did some research and foind this page from microsoft.
http://support.microsoft.com/kb/289675
which is correct as my error throws up the error **** Current Recordset does not support updating. This may be a limitation of the provider, or of the selected *****  now I have been and made the approp changes to the system as below but it keeps throwing up the lock problem, any ideas what to do next

Private Sub Addclass_Click()
    'ACCESS THE DATA FOR THE TABLE ATTENDENCE
On Error GoTo Err_Addclass_Click
    ' CHECK THAT A DATE EXITS AND CLASS AND COURSE EXIST
   
            Dim myconn As New ADODB.Connection
            Dim myrecsetattenexist As New ADODB.Recordset
            Dim StudentID As String ' extract this from the mainform page
            myconn.Open CurrentProject.Connection
            Dim querystringatten As String
          querystringatten = "Select * from Attendance where StudentID = '" &                                                                 
                               Forms!MainForm!Student.Form!StudentID & "' AND DateOfAttend = '" & datrval & "'"
                               
             myrecsetattenexist.Open querystringatten, myconn, adOpenKeyset, adLockPessimistic '
              If myrecsetattenexist.EOF = True Then
                                     
                      myrecset.MoveFirst
                      myrecset.AddNew
                       'MsgBox (ActionDate)
                        myrecset.Fields("StudentID") = Forms!MainForm!Student.Form!StudentID
                       myrecset.Fields("DateOfAttend") = datrval
                       myrecset.Fields("NoOfHrsExpect") = Forms!MainForm!Student.Form!hoursperweek
                       myrecset.Fields("NoOfHrsActual") = 0
                        myrecset.Fields("StudCourseID") =  
                                       Forms![MainForm]![Student].Form![frmsubStudentInfo].Form![CourseID]
                        'MsgBox ("adding")
                         ' myrecset.Fields("ClassID") = "14"
                         myrecset.Update
                                           
                 End If
                               
Exit_Addclass_Click:
    Exit Sub

Err_Addclass_Click:
    MsgBox (Err.Description)
    MsgBox ("Check the dates and Class ID")
    Resume 'Exit_Addclass_Click


End Sub
0
Comment
Question by:sydneyguy
  • 2
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
dosth earned 2000 total points
ID: 21874227
myrecsetattenexist.Open querystringatten, myconn, adOpenKeyset, adLockPessimistic

try

myrecsetattenexist.Open querystringatten, myconn, adOpenKeyset, adLockOptimistic
0
 

Author Comment

by:sydneyguy
ID: 21874253
have tried that as well and still did not work another suggestion? but we must be close
0
 

Author Closing Comment

by:sydneyguy
ID: 31470879
Thanks so much for your help
0
 
LVL 15

Expert Comment

by:dosth
ID: 22435304
thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Viewers will learn how the fundamental information of how to create a table.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question