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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO VBScript SelectSingleNode Error

Status
Not open for further replies.

Marryp

Technical User
May 28, 2001
129
CA
I can't figure out the problem with my code. Error on the SelectSingleNode and it is asking for an object :( Please help!!!

The XML looks like this:

<XMLDocument>
<XMLHeader>
<XMLTitle> Real-Time Streaming ON Market Data File</XMLTitle>
<XMLDocVersion>1</XMLDocVersion>
</XMLHeader>
<XMLDocBody>
<ONMarketInfo>
<Date>20050512</Date>
<Time>15:45:00</Time>
<ONMarketList>
<ONMarketData>
<ID>_Pre_Dispatch_Demand</ID>
<DataDate>20050512</DataDate>
<Hour>15</Hour>
<Interval>1</Interval>
<Value>19186.5</Value>
</ONMarketData>
<ONMarketData>
<ID>_Dispatch_Demand</ID>
<DataDate>20050512</DataDate>
<Hour>14</Hour>
<Interval>1</Interval>
<Value>19203.7</Value>
</ONMarketData>
<ONMarketData>
<ID>_Pre_Dispatch_HOEP_Current_Hour</ID>
<DataDate>20050512</DataDate>
<Hour>15</Hour>
<Interval>1</Interval>
<Value>64.63</Value>
</ONMarketData>
</ONMarketList>
</ONMarketInfo>
</XMLDocBody>
</XMLDocument>



'*****************************************************
' Visual Basic ActiveX Script
'*****************************************************

Function Main()
Dim objXMLDOM
Dim objNodes
Dim objNodes_Info
Dim objMarketNode
Dim LoadDate
Dim LoadTime

Dim objADORS
Dim objADOCnn

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:\NRGenXML\NRGenONMarketFile.xml"

Set objNodes = objXMLDOM.selectNodes("//NRGenONMarketInfo/NRGenONMarketList/NRGenONMarketData")
Set objNodes_Info = objXMLDOM.selectNodes("//NRGenONMarketInfo")

Set objADOCnn = CreateObject("ADODB.Connection")
Set objADORS = CreateObject("ADODB.Recordset")

objADOCnn.Open "PROVIDER=SQLOLEDB;SERVER=.;UID=sa;PWD=;DATABASE=Ops_Energy;"
objADORS.Open "Select * from tmp_ONMarketData where 1 = 2", objADOCnn, adOpenKeyset, adLockOptimistic

Set LoadDate = objNodes_Info.selectSingleNode("Date").nodeTypedvalue
Set LoadTime = objNodes_Info.selectSingleNode("Time").nodeTypedvalue

For Each objMarketNode In objNodes
With objADORS
.AddNew
.fields(LoadDate) = LoadDate
.fields(LoadTime) = LoadTime
.fields("ID") = objMarketNode.selectSingleNode("ID").nodeTypedValue
.fields("DataDate") = objMarketNode.selectSingleNode("DataDate").nodeTypedValue
.fields("MarketData_Hour") = objMarketNode.selectSingleNode("Hour").nodeTypedValue
.fields("MarketData_Interval") = objMarketNode.selectSingleNode("Interval").nodeTypedValue
.fields("MarketData_Value") = objMarketNode.selectSingleNode("Value").nodeTypedValue
.Update
End With
Next


objADORS.Close
objADOCnn.Close

Main = DTSTaskExecResult_Success

End Function

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top