2017-11-16 7 views
0

私はMS Accessの同時性について簡単に質問しています。私はexcelで入力シートを構築し、VBコードはMS Accessデータベースへの接続をオープンして約5ミリ秒で8つのフィールドを記録し、すぐに(特定のユーザーのために)接続を閉じます。私はAccessに並行性の限界があることを認識していますが、これは70人のユーザーにとって本当に知りたいのですか?それらのすべてがまったく同じ時刻にデータを記録するわけではありません。もし起こるとすれば、70人中20〜30人(最も多く)がまったく同じ時刻に何かを記録するかもしれません。MS Access同時アクセスユーザ

また、アクセスデータベースはデータの保存にのみ使用されます。

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 
+0

SharePointリストを使用してAccessにリンクする機能はありますか?もしそうなら、私はそれをするでしょう。 – theMayer

+0

問題ではありません。 – June7

+0

レコードを追加するだけなので、並行性はまったく問題ではありません。競合する可能性はありません。 –

答えて

1

これは問題ではありません。エラーをキャッチして、もう一度やり直してください。

あなたは深刻な問題が発生した場合は、ここで説明する方法を使用することができます。

完全なデモやコードが含まHandle concurrent update conflicts in Access silently

' 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 

と:

' 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 

GitHub