我的解决方案是在本地 SQL Server 实例的存储过程中创建进程,并从 MS Access 表单中调用它。我还创建了一个小函数来在每个用户的 PC 上创建程序,因此我不必手动执行此操作。由于这必须在全州范围内分发给用户,因此该操作在 Access 中进行。为了添加上传检查数据和图片所需的程序,我为每个以下格式创建了一个函数:
Function CreateProcAppendToAncillaryPics()
'Change mouse to hour glass so end user knows something is going on
Screen.MousePointer = 11
Dim Conn As ADODB.Connection
Set Conn = New ADODB.Connection
Dim strCreateProcAncillaryImages As String
Conn.Open ("Driver={SQL Server};Server=localhost\SQLEXPRESS2012;Database=DamInspector")
strCreateProcAncillaryImages = "CREATE PROCEDURE dbo.AppendToAncillaryPics AS " & _
"INSERT INTO [xxx.xxx.xxx.xxx].DamInspector.dbo.AncillaryImages " & _
"(tableVersion, ID, techUName, DamsPhoto, PhotoDescription, structName, marker, thisdate, uuid)" & _
" SELECT " & _
"L.tableVersion, L.ID, L.techUName, L.DamsPhoto, L.PhotoDescription, L.structName, L.marker, L.thisdate, L.uuid" & _
" FROM DamInspector.dbo.AncillaryImages AS L" & _
" LEFT OUTER JOIN " & _
"[xxx.xxx.xxx.xxx].DamInspector.dbo.AncillaryImages AS R " & _
"ON L.uuid = R.uuid " & _
"WHERE " & _
"R.uuid IS NULL;"
Conn.Execute strCreateProcAncillaryImages
Conn.Close
'Set the mouse pointer back to normal
Screen.MousePointer = 0
'Notify the user the process is complete.
MsgBox "Upload Process Completed."
End Function
然后我创建了调用每个存储过程的函数:
Function Call_ProcAppendToGeneralPics()
Screen.MousePointer = 11
Dim Conn As ADODB.Connection
Set Conn = New ADODB.Connection
Conn.Open ("Driver={SQL Server};Server=localhost\SQLEXPRESS2012;Database=DamInspector")
Conn.Execute "AppendToAncillaryPics"
Conn.Execute "AppendToAuxSpillwayPics"
Conn.Execute "AppendToCrestPics"
Conn.Execute "AppendToDownstreamPics"
Conn.Execute "AppendToGeneralPics"
Conn.Execute "AppendToOcPics"
Conn.Execute "AppendToRiserPics"
Conn.Execute "AppendToUpstreamPics"
Conn.Close
Screen.MousePointer = 0
'Notify the user the process is complete.
MsgBox "Upload Process Completed."
End Function
有可能这一切都可以放在一个程序中,但在这个阶段我需要知道,如果插入远程服务器有问题,它在哪里发生故障。到目前为止一切顺利,但我们才刚刚开始。