I am currently rewriting a VBA XML reader to a VB.net version for a project. I have the following code in VBA:
Dim XML_Doc As Object: Set XML_Doc = CreateObject("MSXML2.DOMDocument")
Dim XML_Detail As New ADODB.Recordset: XML_Detail.ActiveConnection =
"Provider=MSDAOSP; Data Source=MSXML2.DSOControl.2.6;"
I was told that I should be able to use almost the exact code in my VB.开发者_JAVA技巧Net version but I am running into some problems. I added as a reference to the VB.net project the Microsoft ActiveX 2.8 so I can use the ADODB.
The code in VB.Net is
Dim XmlDoc As Object : XmlDoc = CreateObject("MSXML2.DOMDocument")
Dim XmlDetail As New ADODB.Recordset : XmlDetail.ActiveConnection =
"Provider=MSDAOSP; Data Source=MSXML2.DSOControl.2.6;"
When running the application it gets to the XmlDetail and throws the following error:
System.Runtime.InteropServices.COMException was unhandled.
Arguments are of the wrong type, are out of acceptable range,
or are in conflict with one another.
Does anyone have any experience with this or how I can resolve it?
Thanks
You're not supposed to use MSXML in .Net:
The use of MSXML is not supported in .NET applications
http://support.microsoft.com/kb/815112
Even More Details:
http://blogs.msdn.com/b/alejacma/archive/2008/09/08/the-use-of-msxml-is-not-supported-in-net-applications.aspx
After alot of work I found a solution:
Dim XmlDoc As Object : XmlDoc = CreateObject("MSXML2.DOMDocument")
XmlDetail.Open(DirSaveXml & ServiceName & ".xml", "Provider=MSDAOSP; Data Source=MSXML2.DSOControl.2.6;")
精彩评论