Hi all,
I have a DTS-task below that basically updates two fields in a SQL-server table from a XML-file.
The "Street" node exist on many records.
The "DateSentAt" exist only once per file. But I want the value in "DateSentAt" to be in all records in the table.
My problem is that the loop stops after the first record.
I don't understand why.
Const adOpenKeyset = 1
Const adLockOptimistic = 3
Set objXMLDOM = CreateObject("MSXML2.DOMDocument.4.0")
objXMLDOM.async = False
objXMLDOM.validateOnParse = False
'No error handling done
objXMLDOM.load "c:\041005kundmaster_prd002BF.xml"
Set objNodes = objXMLDOM.selectNodes("/BusinessPartners_Update")
Set objADOCnn = CreateObject("ADODB.Connection")
Set objADORS = CreateObject("ADODB.Recordset")
objADOCnn.Open "PROVIDER=SQLOLEDB;SERVER=.;UID=sa;PWD=hurra;DATABASE=NorthWind;"
objADORS.Open "SELECT * FROM TblKundreg WHERE 1 = 2", objADOCnn, adOpenKeyset, adLockOptimistic
Set DateSentAtNode = objXMLDOM.selectSingleNode("/BusinessPartners_Update/Head/Properties/DateSentAt")
For Each objBookNode In objNodes
Set streetNode = objBookNode.selectSingleNode("Body/BusinessPartner/Address/Street")
With objADORS
.AddNew
If Not streetNode Is Nothing Then .fields("Street") = streetNode.NodeTypedValue end if
.fields("DateSentAt") =DateSentAtNode.NodeTypedValue
.Update
End With
Next
objADORS.Close
objADOCnn.Close
Main = DTSTaskExecResult_Success
I have a DTS-task below that basically updates two fields in a SQL-server table from a XML-file.
The "Street" node exist on many records.
The "DateSentAt" exist only once per file. But I want the value in "DateSentAt" to be in all records in the table.
My problem is that the loop stops after the first record.
I don't understand why.
Const adOpenKeyset = 1
Const adLockOptimistic = 3
Set objXMLDOM = CreateObject("MSXML2.DOMDocument.4.0")
objXMLDOM.async = False
objXMLDOM.validateOnParse = False
'No error handling done
objXMLDOM.load "c:\041005kundmaster_prd002BF.xml"
Set objNodes = objXMLDOM.selectNodes("/BusinessPartners_Update")
Set objADOCnn = CreateObject("ADODB.Connection")
Set objADORS = CreateObject("ADODB.Recordset")
objADOCnn.Open "PROVIDER=SQLOLEDB;SERVER=.;UID=sa;PWD=hurra;DATABASE=NorthWind;"
objADORS.Open "SELECT * FROM TblKundreg WHERE 1 = 2", objADOCnn, adOpenKeyset, adLockOptimistic
Set DateSentAtNode = objXMLDOM.selectSingleNode("/BusinessPartners_Update/Head/Properties/DateSentAt")
For Each objBookNode In objNodes
Set streetNode = objBookNode.selectSingleNode("Body/BusinessPartner/Address/Street")
With objADORS
.AddNew
If Not streetNode Is Nothing Then .fields("Street") = streetNode.NodeTypedValue end if
.fields("DateSentAt") =DateSentAtNode.NodeTypedValue
.Update
End With
Next
objADORS.Close
objADOCnn.Close
Main = DTSTaskExecResult_Success