Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loop stops..?

Status
Not open for further replies.

kenjoswe

Technical User
Sep 19, 2000
327
SE
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



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top