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
|