Object不支持此属性或方法:记录集上的'eof'从xml打开

时间:2012-01-25 15:35:29

标签: c# xml asp-classic recordset

我从一个.net webservice调用一些xml,并希望将其转回记录集,以便我可以将它与经典的asp网站一起使用。 一切顺利,直到我去

 do until rs.eof

然后我收到上述错误。

我的代码调用webservice:

 Dim xmlhttp
    Dim postUrl
    postUrl = "http://localhost:9065/Interrogator.asmx/TestRecordSet"

    Set xmlhttp = server.Createobject("MSXML2.XMLHTTP")
    xmlhttp.Open "POST",postUrl,false
    xmlhttp.setRequestHeader "Content-Type","application/x-www-form-urlencoded"
    xmlhttp.send()
    xml =xmlhttp.responseText
    set dom = server.createobject("microsoft.xmldom")
    dom.loadXML(xml)
   ''# get the actual value
    set node = dom.selectsinglenode("//string")
    rs= RecordsetFromXMLString(node.text)
      do until rs.eof <---- ERROR HERE
            response.Write(rs("ID"))
      rs.movenext : loop

我的代码将xml转换为记录集:

    Public Function RecordsetFromXMLString(sXML)

    Dim oStream
    Set oStream = server.createobject("ADODB.Stream")
    oStream.Charset = "iso-8859-1"
    oStream.Open
    oStream.WriteText sXML   ''# Give the XML string to the ADO Stream
    oStream.Position = 0    ''# Set the stream position to the start    
    Dim oRecordset
    Set oRecordset = server.createobject("ADODB.Recordset")       
    oRecordset.Open oStream    ''# Open a recordset from the stream
    oStream.Close
    Set oStream = Nothing
    Set RecordsetFromXMLString = oRecordset  ''# Return the recordset
    Set oRecordset = Nothing
End Function

我的Xml是这样的:

    <xml xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'
    xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'
    xmlns:rs='urn:schemas-microsoft-com:rowset'
    xmlns:z='#RowsetSchema'>
<s:Schema id='RowsetSchema'>
    <s:ElementType name='row' content='eltOnly' rs:updatable='true'>
        <s:AttributeType name='ID' rs:number='1' rs:write='true'>
            <s:datatype dt:type='int' dt:maxLength='4' rs:precision='0'
             rs:fixedlength='true' rs:maybenull='false'/>
        </s:AttributeType>
        <s:AttributeType name='Name' rs:number='2' rs:write='true'>
            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='1000'
             rs:precision='0' rs:maybenull='false'/>
        </s:AttributeType>
        <s:AttributeType name='SomethingElse' rs:number='3'
             rs:write='true'>
            <s:datatype dt:type='string' rs:dbtype='str' dt:maxLength='1000'
             rs:precision='0' rs:maybenull='false'/>
        </s:AttributeType>
        <s:extends type='rs:rowbase'/>
    </s:ElementType>
</s:Schema>
<rs:data>
    <rs:insert>
        <z:row ID='1'/>
        <z:row Name='Name0'/>
        <z:row Name='blah blah0'/>
        <z:row ID='2'/>
        <z:row Name='Name1'/>
        <z:row Name='blah blah1'/>

    </rs:insert>
</rs:data>
</xml>

我认为这与需要断开连接的记录集有关,但我尝试添加

    oRecordset .LockType =adLockBatchOptimistic
oRecordset .CursorLocation = adUseClient

正如我在.net方面所做的那样,除了它之外它不会!我可能完全错了,因为我是一名c#.net开发人员,绝对不是经典的asp,我发现这很困难。

谁能看到我做错了什么?

1 个答案:

答案 0 :(得分:2)

我认为你需要让rs成为一个对象,试试这个:

set rs= RecordsetFromXMLString(node.text)