我开始遇到数据库的并发问题。我在办公室网络的共享位置有大约十个不同的aacdb文件。其中一个数据库是“主”数据库。它分为后端和前端。此数据库的后端包含常用表,如用户/密码,员工,部门等。
昨天,我制作了两个纯粹用于输入的数据库。它们在“数据输入”模式下都有一个绑定到表的表单,记录锁设置为“编辑记录”。它们还链接到其他数据库共享的一些相同表。这是我第一次遇到(可能是?)并发问题的地方。
人们一直在'master'数据库中报告奇怪的行为(表格没有打开等)。这进行了一些测试,只有当用户也在链接的数据条目数据库中时才会发生。
在给定时间内,所有数据库中的当前用户仍然不到10个。
下拉选项是否会锁定表格,阻止某些表单打开? AFAIK,只在表单加载时查询下拉列表。
有什么想法吗?
答案 0 :(得分:1)
我适应了这个问题,尝试让多个用户从网络共享共享同一个前端。事情只会......不起作用。然后,当我回去时,不可能重复失败。我决定在本地计算机上安装应用程序,但这有版本控制问题,特别是因为我有几个不同的前端同时运行不同的项目。有更新程序,但他们要么花钱,要么我看不到代码,不相信他们。我想出了这个解决方案,自Access 2003以来一直在使用它。
这是一个单独的ACCESS数据库,您必须像对待任何前端一样将其锁定。
此启动器适用于我现在正在运行的四个访问前端。您必须在网络上设置两个表。
TABLE NAME:RunTimeTracking
FIELD:RTTID:AutoNumber
FIELD:RTTComputerName:Text
FIELD:RTTLoginTime:日期/时间
TABLE NAME:VersionControlTable
FIELD:VCTID:AutoNumber
FIELD:VCTVersion:Number
FIELD:VCTSourceLoc:文本
FIELD:VCTDest:文字
FIELD:VCTDateVer:日期/时间
RunTimeTracking表用于防止用户在不使用启动器的情况下启动实际应用程序。当启动器运行时,它会在表中插入一个带有计算机名称的条目。当应用程序运行时,它会查找该条目,如果它没有看到它。它警告并转储。
在版本控制表中,放置最新应用程序的位置,即本地计算机上要存储应用程序的位置。
如果您有多个正在控制的程序,请增加VCTVersion条目并在启动器的代码中引用它。
strSQL = "SELECT * FROM VersionControlTable WHERE VCTVersion = 200"
当启动器运行时,它会将本地文件上的CREATED日期戳检查到网络上的日期戳,如果它们不同,则会复制。如果没有,它会运行。
Private Sub Form_Load()
DoCmd.ShowToolbar "Ribbon", acToolbarNo
DoCmd.ShowToolbar "Status Bar", acToolbarNo
DoCmd.Maximize
Form.TimerInterval = 2000
End Sub
Private Sub Form_Timer()
runDataCheck
End Sub
Private Sub runDataCheck()
' This is the launcher program. This program is designed to check for
' Version information and upload and download the new version automaticaly.
' Place entry into the Run Time Tracking Table. This will be used by the Main Application to verify that
' The application was launched by the Launcher and not run straight from the desktop
'First, retrieve the name of the computer from the Environment.
Dim strCompName As String
strCompName = Environ("computername")
' Now, delete all entries on the tracking table that have this computer name associated with it.
' Later we will try to add a trigger that archives the logins.
Dim strSQL As String
strSQL = "DELETE FROM RunTimeTracking WHERE RTTComputerName = '" & strCompName & "'"
adoSQLexec (strSQL)
' Now, add and entry into the table
strSQL = "INSERT INTO RunTimeTracking (RTTComputerName,RTTLoginTime) VALUES ('" & strCompName & "','" & Now() & "')"
adoSQLexec (strSQL)
' First, retrieve the parameters from the Version Control File and put them into variables that we can use.
Dim strSource As String
Dim strDest As String
Dim dateVer As Date
Dim rs As New ADODB.Recordset
'LBLSplashLabel.Caption = "Checking Version Information...."
strSQL = "SELECT * FROM VersionControlTable WHERE VCTVersion = 200"
With rs
rs.Open strSQL, CurrentProject.Connection
End With
strSource = rs.Fields("VCTSourceLoc").Value
strDest = rs.Fields("VCTDest").Value
dateVer = rs.Fields("VCTDateVer").Value
Set rs = Nothing
' Next. See if the folders on both the local drive and the source drive exists.
Dim binLocal As Boolean
Dim binNet As Boolean
Dim binDirectoryLocal As Boolean
'Debug.Print strSource
' First check to see if the network file exists.
binNet = FileExists(strSource)
If binNet = False Then
MsgBox ("The network source files are missing. Please contact Maintenance!")
Application.Quit (acQuitSaveNone)
End If
' Get the timestamp from the network version since it exists.
Dim fileNet As File
Dim fileLocal As File
Dim fileNetObject As New FileSystemObject
Set fileNet = fileNetObject.GetFile(strSource)
Debug.Print strSource
Debug.Print "Created Date : " & fileNet.DateCreated
Dim strDirName As String
Dim intFind As Integer
' Check to see if the Local file Exists.
binLocal = FileExists(strDest)
If binLocal = False Then
'There is no local file. Check to see if the directory exists
' Get the directory name
intFind = (InStrRev(strDest, "\", , vbTextCompare))
strDirName = (Left(strDest, intFind - 1))
Debug.Print "Directory Name: " & strDirName
binDirectoryLocal = FolderExists(strDirName)
If binDirectoryLocal = False Then
'There is no local directory. Create one
MkDir (strDirName)
' LBLSplashLabel.Caption = "Copying Files...."
'Copy the source file to the directory.
FileCopy strSource, strDest
'Since we have no copied the latest version over, no need to continue. Open the main app
OpenMaintApp (strDest)
Else
' No need to create the directory, simply copy the file.
'Copy the source file to the directory.
' LBLSplashLabel.Caption = "Copying Files...."
FileCopy strSource, strDest
'Since we have no copied the latest version over, no need to continue. Open the main app
OpenMaintApp (strDest)
End If
End If
'Now we know that the file is in the directory, now we need to check its version.
'Get the last modified date from the file.
Set fileLocal = fileNetObject.GetFile(strDest)
Debug.Print "Last Modified Date : " & fileLocal.DateCreated
'Do the version check
If fileLocal.DateCreated <> fileNet.DateCreated Then
' LBLSplashLabel.Caption = "Copying Files...."
'Copy the source file to the directory.
FileCopy strSource, strDest
'Since we have no copied the latest version over, no need to continue. Open the main app
OpenMaintApp (strDest)
Else
OpenMaintApp (strDest)
End If
OpenMaintApp (strDest)
End Sub
Private Sub OpenMaintApp(strAppName As String)
Dim accapp As Access.Application
Set accapp = New Access.Application
accapp.OpenCurrentDatabase (strAppName)
accapp.Visible = True
DoCmd.Quit acQuitSaveNone
End Sub