I just have a quick question on MS Access Concurrency. I have built an input sheet in excel and the VB code opens a connection to a MS Access database logs 8 fields in about 5 milliseconds and closes the connection right away (for that particular user). I realize that Access has its limitations with concurrency, but what I really want to know if this is okay for 70 users? Not all of them will be logging data at the exact same time, if that would happen, I would say like 20-30 out of the 70 (the most) might log something at the exact same time.
On another note, the Access Database is only used for storing data, nothing else.
Dim NewCon As ADODB.Connection
Set NewCon = New ADODB.Connection
Dim Recordset As ADODB.Recordset
Set Recordset = New ADODB.Recordset
NewCon.Open "Provider=Microsoft.ace.oledb.12.0;Data Source=C:\Users\my.user\Desktop\Testing\Database1.accdb"
Recordset.Open "DATA", NewCon, adOpenDynamic, adLockOptimistic
Recordset.AddNew
'Primary Key
Recordset.Fields(0).Value = G
'Field 2
Recordset.Fields(1).Value = A
'Field 3
Recordset.Fields(2).Value = B
'Field 4
Recordset.Fields(3).Value = C
'Field 5
Recordset.Fields(4).Value = D
'Field 6
Recordset.Fields(5).Value = E
'Field 7
Recordset.Fields(6).Value = F
'Field 8
Recordset.Fields(7).Value = Format(Now, "m/d/yyyy h:mm:ss")
Recordset.Update
Recordset.Close
NewCon.Close
It should not be an issue. Or catch an error and try again.
If you experience serious trouble, you can use the method described here:
Handle concurrent update conflicts in Access silently
which includes a full demo and code:
' Function to replace the Edit method of a DAO.Recordset.
' To be used followed by GetUpdate to automatically handle
' concurrent updates.
'
' 2016-02-06. Gustav Brock, Cactus Data ApS, CPH.
'
Public Sub SetEdit(ByRef rs As DAO.Recordset)
On Error GoTo Err_SetEdit
' Attempt to set rs into edit mode.
Do While rs.EditMode <> dbEditInProgress
rs.Edit
If rs.EditMode = dbEditInProgress Then
' rs is ready for edit.
Exit Do
End If
Loop
Exit_SetEdit:
Exit Sub
Err_SetEdit:
If DebugMode Then Debug.Print " Edit", Timer, Err.Description
If Err.Number = 3197 Then
' Concurrent edit.
' Continue in the loop.
' Will normally happen ONCE only for each call of SetEdit.
Resume Next
Else
' Other error, like deleted record.
' Pass error handling to the calling procedure.
Resume Exit_SetEdit
End If
End Sub
and:
' Function to replace the Update method of a DAO.Recordset.
' To be used following SetEdit to automatically handle
' concurrent updates.
'
' 2016-01-31. Gustav Brock, Cactus Data ApS, CPH.
'
Public Function GetUpdate(ByRef rs As DAO.Recordset) As Boolean
On Error GoTo Err_GetUpdate
' Attempt to update rs and terminate edit mode.
rs.Update
GetUpdate = True
Exit_GetUpdate:
Exit Function
Err_GetUpdate:
If DebugMode Then Debug.Print " Update", Timer, Err.Description
' Update failed.
' Cancel and return False.
rs.CancelUpdate
Resume Exit_GetUpdate
End Function
Also at GitHub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.