我正试图修复从Access 97格式导入到Access 2007格式的Microsoft Access数据库。MDB到.accdb)。导入是成功的,我能够使数据库在我的机器上完全正常工作。它在我同事的机器上也能正常工作。然而,当被带到属于我们组织的另一个建筑物时,我们无法使数据库运行。我们知道,问题的一部分是在打开到保存中央数据库的web服务器的连接(这个Access数据库有几个副本,由相同的代码组成,但输入不同的数据并上传到这个中央数据库)。代码如下:
Public Function updateSqlServer(TransType As String, SqlCommand As Variant) As Boolean
Dim xmldom As New MSXML2.DOMDocument40
Dim xmlhttp As New MSXML2.ServerXMLHTTP40
Const SoapServer = "http://www.example.com/webservice.asp"
'setup the XMLHTTP object and POST envelope to SoapServer
toResolve = 5 * 1000
toConnect = 5 * 1000
toSend = 15 * 1000
toReceive = 15 * 1000
xmlhttp.setTimeouts toResolve, toConnect, toSend, toReceive
xmlhttp.Open "POST", SoapServer, False 'YIELDS Run-Time Error 429 on this line: xmlhttp.Open
xmlhttp.setRequestHeader "Man", POST & " " & SoapServer & " HTTP/1.1"
xmlhttp.setRequestHeader "MessageType", "CALL"
xmlhttp.setRequestHeader "Content-Type", "text/xml"
xmlhttp.send (SoapEnvelope)
'synchronous wait for response; HTTP status other than 200 (OK) is an error
If xmlhttp.Status = 200 Then
Set xmldom = xmlhttp.responseXML 'get response into XML DOM document
Debug.Print (xmldom.xml) 'write soap response to screen
updateSqlServer = True
Else
'handle error
Debug.Print ("Didn't Work")
Debug.Print ("status=" & xmlhttp.Status) 'write soap return code
Debug.Print ("" & xmlhttp.statusText) 'write status text
updateSqlServer = False
End If
Set xmlhttp = Nothing
Set xmldom = Nothing
End Function
我们试图解决这个问题的事情:1. 添加了所有必要的引用(例如Microsoft XML)2. 编辑文件和文件夹的权限3.注册ActiveX控件4. 确保所有可更改的选项在工作和非工作机器上都匹配
这个旧的,不是我的代码或设计。我得把它修好。任何帮助都将不胜感激。
我的一个同事找到了答案。这些变量是MSXML4的对象,而Windows 7自带 msxml6.0 ,这显然与MSXML4不兼容。
确保检查安装包。
您可以安装MSXML 4或将变量更改为MSXML 6
:
Dim xmldom As New MSXML2.DOMDocument6.0
不是Dim xmldom As New MSXML2.DOMDocument40