Mango_Lier
Posts: 110
|
Posted: 02/02/2007, 3:28 PM |
|
After all the ground work is done as described in Part 1… http://forums.yessoftware.com/posts.php?post_id=84477
1) Expand common files node in the Project Explorer and open the “common.asp” file in the editor. Scroll all the way down and paste the following code between the “grey” area and the %>.
============CODE===============
Sub OutputXMLError(strMessage)
Response.Buffer = TRUE
Response.ContentType = "text/xml"
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1
Response.Write("<error>")
Response.Write("<message>")
Response.Write strMessage
Response.Write("</message>")
Response.Write("</error>")
Response.Flush
Response.End
End Sub
Sub OutputXML(RecordSet, XSLTransform)
Dim InputXMLDom, InputXLSDom, OutputXMLDom
Response.Buffer = TRUE
Response.ContentType = "text/xml"
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1
Set InputXMLDom = CreateObject("MSXML.DOMDocument")
RecordSet.Save InputXMLDom, 1
if Len(XSLTransform)=0 Then
Response.Write InputXMLDom.XML
Else
Set InputXLSDom = CreateObject("MSXML.DOMDocument")
InputXLSDom.load(Server.MapPath(XSLTransform))
Set OutputXMLDom = CreateObject("MSXML.DOMDocument")
Call InputXMLDom.transformNodetoObject(InputXLSDom, OutputXMLDom)
Response.Write OutputXMLDom.XML
End If
Response.Flush
Response.End
set OutputXMLDom = Nothing
set InputXMLDom = Nothing
set InputXLSDom = Nothing
End Sub
=============================
The code above prints the record set in XML form. For more info see: http://www.4guysfromrolla.com/webtech/041404-1.shtml
Save the file and close it.
2) By default the grid only pulls 20 records out of the database at a time (this can be changed in the properties window). We will change it via code.
3) open “dataislandXML” file in the editor. Select “MyXmlData” form in the project explorer and select “events” tab in the properties window (lower left hand corner)
4) For the server side events, select “Before Select” and add the following code.
MyXmlData.PageSize = 10000
The code above changes the page size so we pull 10,000 records from the DB. The intent is to get all the records. There are better ways to implement this event, but it is sufficient for this example.
5) Now select the “dataislandXML” page in the project explorer and add code to “Before Output” server side event
==== code ===
If MyXmlData.Errors.Count > 0 Then
Call OutputXMLError(MyXmlData.Errors.ToString)
Else
Call OutputXML(MyXmlData.Recordset.RecordSet, "")
End If
===========
Save the file and publish the project. With dataislandXML open in the editor do a “Shift +F10” to open the page in browser. After the login prompt, instead of the old grid you will get XML output for the recordset.
In part 3, we will hook up this XML with OWC pivot table and chart components.
|
|
|
|
|
|
|
|