您是否試過保持連接打開?這可能只適用於另一個accdb中的鏈接表,不確定。
我有這個問題而回,所以我現在保持連接打開,只要訪問正在運行,這是我分了這一個精簡版本:
Public Sub updateTables(bClose As Boolean)
Dim dbsCurrent As Database
Dim tdfSingle As TableDef
Dim tdfCollection As TableDefs
Dim sBasePath As String, sPath As String
Set dbsCurrent = CurrentDb
Set tdfCollection = dbsCurrent.TableDefs
Set dbsHold = dbsCurrent
Static dbsOpen As DAO.Database
If bClose Then
dbsOpen.Close
Else
sBasePath = Left(CurrentDb.Name, InStrRev(CurrentDb.Name, "\")) & "SB-Support\"
sPath = GetUNC(sBasePath & "data.dat")
Set dbsOpen = OpenDatabase(sPath, False, False, "MS Access;")
For Each tdfSingle In tdfCollection
If tdfSingle.SourceTableName <> "" Then
If tdfSingle.Fields.Count = 0 Then
tdfSingle.Connect = ";DATABASE=" & sPath
tdfSingle.RefreshLink
End If
End If
Next
End If
Exit Sub
末次
我想我最初檢索它從這裏: http://www.fmsinc.com/microsoftaccess/performance/linkeddatabase.html
我沒有SQL服務器的要求,但快速谷歌給了我這個對的openDatabase的SQL連接:
Dim cs As String
Dim cn As DAO.Database
Dim ws As DAO.Workspace
Set ws = DBEngine.Workspaces(0)
cs = "ODBC;DRIVER=SQL Server;SERVER=Main\SQLEXPRESS;DATABASE=Workwise;APP=Visual Basic" 'UID=Peter;PWD="
Set cn = ws.OpenDatabase("Workwise", dbDriverNoPrompt, True, cs)
http://www.vbforums.com/archive/index.php/t-572723.html
是否有任何原因導致您沒有將SQL Server 2000升級到SQL Server 2008 Express之類的東西? – HK1 2012-04-12 19:20:11
您是否看到http://social.technet.microsoft.com/Forums/zh-cn/office2007deploymentcompatibility/thread/88542372-0fcb-4521-87ec-e2ab72e688dd? – Fionnuala 2012-04-12 21:58:54
當專用數據庫服務器正在使用時,避免鏈接表總是最好的,充分利用其處理能力並始終採用ADO連接方式。這將使服務器執行所有工作,除了在訪問之外無法完成的任何事情之外。 – 2012-04-13 08:29:43