SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Dec 2004
    Location
    brasil
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question join tables with xml ?

    Good morning everybody,

    I just started a new job as a web developer in witch I have to deal with web services... I Know that websevices could make my life easier but right now they kind of scare me.

    So I came here looking for help and in return I can try to help others with the my php and asp experience.

    Here is my problem:

    I got some xml code that is already working, but the person who did it doesnt work here anymore...

    the code is a function that returns data from a field called notes in a table called books in a MSSQL server database

    this data could be of 48 diferent types

    the code creates rows in a table with the name(description) and the data from each of the 48 types but only if the data isnt NULL

    that is working just fine...

    but there is another table called notes_types that have only 2 fields:
    a primary key called note(codes from 1 to 48)
    and a field called visible.

    So if visible = 0 it was not supose to show those types even if they are not nulll

    here is the code:

    '--------------------------------------------------
    ' Convers the field NOTES in XML to appear in a asp page-
    '------------------------------------------------

    Function Format_Notes(stringXML)
    Set xmlDoc = CreateObject("Microsoft.xmldom")
    xmlDoc.async = False
    xmlDoc.loadxml stringXML
    Set xmlRoot = xmlDoc.documentElement
    For Each xmlPNode In xmlRoot.childNodes
    If xmlPNode.childNodes.length = 0 Then
    strDoc = strDoc & ""
    Else
    strDoc = strDoc & "<TABLE >"
    For Each xmlNode In xmlPNode.childNodes
    if xmlNode.nodeName = "ROW" then
    strDoc = strDoc & "<tr>"
    strDoc = strDoc & "<td >img</td>"
    Type = xmlNode.attributes.getNamedItem("Type").value

    Type = Db.Execute("SELECT Description FROM Notes WHERE Tag="&Type).fields(0).value

    strDoc = strDoc & "<td>&nbsp;"&Type&": </td>"
    strDoc = strDoc & "<td>&nbsp;" & xmlNode.attributes.getNamedItem("Notes").value & "</td>"
    strDoc = strDoc & "</tr>"
    end if
    Next
    strDoc = strDoc & "</TABLE>"
    End If
    Format_Notes = strDoc
    Next
    End Function


    so I tried changing th line in sienna color to:

    Type = Db.Execute("SELECT N.Description FROM Notes N, Notes_Types T WHERE N.Code = T.Note AND T.Visible = 1 AND N.Tag="&Type).fields(0).value

    but I got the following message:

    ADODB.Field (0x800A0BCD)
    Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

    I have an idea of what is wrong but I dont know how to proceed...

    Please help

    Thanks
    Last edited by jones_brasil; Dec 7, 2004 at 07:19.

  2. #2
    SitePoint Member
    Join Date
    Dec 2004
    Location
    brasil
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i finnaly solved the problem by doing this


    Function Format_Notes(stringXML)
    Set xmlDoc = CreateObject("Microsoft.xmldom")
    xmlDoc.async = False
    xmlDoc.loadxml stringXML
    Set xmlRoot = xmlDoc.documentElement
    For Each xmlPNode In xmlRoot.childNodes
    If xmlPNode.childNodes.length = 0 Then
    strDoc = strDoc & ""
    Else
    strDoc = strDoc & "<TABLE >"
    For Each xmlNode In xmlPNode.childNodes
    if xmlNode.nodeName = "ROW" then
    Type = xmlNode.attributes.getNamedItem("Type").value
    Type = Db.Execute("SELECT Description FROM Notes WHERE Tag="&Type).fields(0).value
    temp = xmlNode.attributes.getNamedItem("Type").value
    temp = Db.Execute("SELECT T.Visible FROM Notes_TC T, Notes N WHERE N.Code = T.Note and N.Tag ="&temp).fields(0).value
    if temp = 1 then
    strDoc = strDoc & "<tr bgcolor='#ffffff'>"
    strDoc = strDoc & "<td>img</td>"
    strDoc = strDoc & "<td>&nbsp;"&Tipo&": </td>"
    strDoc = strDoc & "<td>&nbsp;" & xmlNode.attributes.getNamedItem("Notes").value & "</td>"
    strDoc = strDoc & "</tr>"
    end if
    end if
    Next
    strDoc = strDoc & "</TABLE>"
    End If
    Format_Notes = strDoc
    Next
    End Function


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •