Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP XML Using ASP 3 and XML. See also the XML category for more XML discussions not relating to ASP. NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP XML section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Closed Thread
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 23rd, 2004, 04:36 PM
Registered User
 
Join Date: Dec 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Any Ideas?????

hi folks,
it originally comes from microsoft kb258295. i modified a little bit. the second button works fine, but not the first one. any ideas?????
step1 - create a dsn name as Northwind.
step2 - create "sample.htm" as follow
<HTML>
    <HEAD>
        <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
        <TITLE>XML Data Binding Sample</TITLE>
    </HEAD>

    <SCRIPT LANGUAGE="VBScript">
        Sub cmdData1_OnClick
            If Data1.style.display = "" Then
                Data1.style.display = "none"
                cmdData1.value = "Hide table bound to straight XML."
            Else
                Data1.style.display = ""
                cmdData1.value = "Click to see table bound to straight XML."
            End If
        End Sub

        Sub cmdData2_OnClick
            If Data2.style.display = "" Then
                Data2.style.display = "none"
                cmdData2.value = "Hide table bound to a persisted recordset."
            Else
                Data2.style.display = ""
                cmdData2.value = "Click to see table bound to a persisted recordset."
            End If
        End Sub
    </SCRIPT>

    <BODY>
        <xml id="PersistedRS" src="Sample.asp?RS=1"></xml>
        <xml id="StraightXML" src="Sample.asp"></xml>

        <INPUT TYPE=button
                NAME="cmdData1"
                VALUE="Click to see table bound to straight XML."
                STYLE="width:300;">

        <BR><BR>

        <TABLE ID=Data1 DATASRC="#StraightXML" BORDER=1 ALIGN=center STYLE="display:none;">
            <THEAD>
                <TR>
                    <TH COLSPAN=11>This table is bound directly to an XML data source.</TH>
                </TR>
                <TR>
                    <TH>Customer ID</TH>
                    <TH>Company Name</TH>
                    <TH>Contact Name</TH>
                    <TH>Country</TH>
                </TR>
            </THEAD>
            <TR>
                <TD><SPAN DATAFLD="CustomerID"></SPAN></TD>
                <TD><SPAN DATAFLD="CompanyName"></SPAN></TD>
                <TD><SPAN DATAFLD="ContactName"></SPAN></TD>
                <TD><SPAN DATAFLD="Country"></SPAN></TD>
            </TR>
        </TABLE>

        <BR><BR>

        <INPUT TYPE=button
                NAME="cmdData2"
                VALUE="Click to see table bound to a persisted recordset."
                STYLE="width:300;">

        <BR><BR>

        <TABLE ID=Data2
                DATASRC="#PersistedRS"
                DATAFLD="rs:data"
                STYLE="display:none;"
                ALIGN=center
                CELLSPACING=0
                CELLPADDING=0>
            <TR><TD>
                <TABLE DATASRC="#PersistedRS" DATAFLD="z:row" BORDER=1 ALIGN=center>
                    <THEAD>
                        <TR>
                            <TH COLSPAN=11>This table is bound directly to an XML data source.</TH>
                        </TR>
                        <TR>
                            <TH>Customer ID</TH>
                            <TH>Company Name</TH>
                            <TH>Contact Name</TH>
                            <TH>Country</TH>
                        </TR>
                    </THEAD>
                    <TR>
                        <TD><SPAN DATAFLD="CustomerID"></SPAN></TD>
                        <TD><SPAN DATAFLD="CompanyName"></SPAN></TD>
                        <TD><SPAN DATAFLD="ContactName"></SPAN></TD>
                        <TD><SPAN DATAFLD="Country"></SPAN></TD>
                    </TR>
                </TABLE>
            </TD></TR>
        </TABLE>
    </BODY>
</HTML>


step3 create "sample.asp" page as follow
<%@ Language=VBScript %>
<%

    const adPersistXML = 1

    dim rs, cn

    Response.ContentType = "text/xml"

    set rs = Server.CreateObject("ADODB.Recordset")
    set cn = Server.CreateObject("ADODB.Connection")
    cn.Open "DSN=Northwind;UID=yourID;PWD=yourPWD;"

    rs.Open "SELECT CustomerID, CompanyName, " & _
            "ContactName, Country FROM Customers WHERE Region = 'SP'", cn

    if Request.QueryString("RS")="1" then
        rs.Save Response, adPersistXML
    else
        dim x, i
        i = 1
        Response.Write "<?xml version=""1.0""?>"
        Response.Write "<DATA>"
        while not rs.EOF
            Response.Write "<RECORD" & i & ">"
            for x = 0 to rs.Fields.Count - 1
                Response.Write "<" + rs.Fields(x).Name + ">"
                If not isnull(rs.Fields(x).Value) then
                    Response.Write Server.HTMLEncode(trim(cstr(rs.Fields(x).Value)))
                Else
                    Response.Write ""
                End if
                Response.Write "</" + rs.Fields(x).Name + ">"
            next
            Response.Write "</RECORD" & i & ">"
            i = i + 1
            rs.MoveNext
        wend
        Response.Write "</DATA>"

    end if

    rs.Close
    cn.Close
    set rs = nothing
    set cn = nothing
%>
step4 run the "sampel.htm" page
click on the 2 buttons. second one works fine. not the first one.

thanks JB

Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sub Form Ideas lord_jawad@hotmail.com VB Databases Basics 8 January 29th, 2007 02:10 AM
PLEASE HELP - I need ideas brettk_1 ASP.NET 1.0 and 1.1 Professional 1 July 13th, 2005 12:42 PM
PLEASE HELP - I need ideas brettk_1 ASP.NET 1.0 and 1.1 Basics 1 July 13th, 2005 12:42 PM



All times are GMT -4. The time now is 01:17 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.