471,317 Members | 2,156 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,317 software developers and data experts.

Trying to generate dynamic xml using aspx

Sorry, but I'm pretty new to .NET/XML etc...

I have the current code which I'm trying to output dynamically so it can be read into a flash file. The only issue is, it doesn't seem to actually do anything. What am I missing? I have been able to output to an xml file, but not dynamically.

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ OutputCache Duration="1" VaryByParam="none" %>

<script runat="server">

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim DBConnection As OleDbConnection
Dim DBAdapter As OleDbDataAdapter
Dim SQLString As String
Dim BacklogDS As DataSet
Dim day30Str As String = "30 Day"
Dim day60Str As String = "60 Day"
Dim day90Str As String = "90 Day"
Dim dayTotalStr As String = "Total"
Dim nullStr As String = ""
Dim day30Int As Integer
Dim day60Int As Integer
Dim day90Int As Integer
Dim dayTotalInt As Integer
'Set variable depatmentStr static for testing
Dim departmentStr As String = "0127"
'Set variable depatmentStr static for testing
Dim departmentBackStr As String = "Department " + departmentStr + " Backlog"

'Connect to DailyLoad.mdb
'Query "SELECT TOP 1 EUPLoad30, EUPLoad60, EUPLoad90, EUPLoadTTL FROM tblEupdaily WHERE (Department = '" & DropDownList1.SelectedItem.Text & "') ORDER BY dateDaily DESC"
DBConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
SQLString = "SELECT TOP 1 EUPLoad30, EUPLoad60, EUPLoad90, EUPLoadTTL FROM tblEupdaily WHERE (Department = '" & departmentStr & "') ORDER BY dateDaily DESC"
DBAdapter = New OleDbDataAdapter(SQLString, DBConnection)

'write query to DataSet
BacklogDS = New DataSet("chart")
DBAdapter.Fill(BacklogDS, "chart")

'assign variables from DataSet
day30Int = BacklogDS.Tables("chart").Rows(0)("EUPLoad30")
day60Int = BacklogDS.Tables("chart").Rows(0)("EUPLoad60")
day90Int = BacklogDS.Tables("chart").Rows(0)("EUPLoad90")
dayTotalInt = BacklogDS.Tables("chart").Rows(0)("EUPLoadTTL")

'create chart_xml.xml
Dim rank As Integer = 1
Dim settings As New XmlWriterSettings()
settings.Indent = True
settings.NewLineOnAttributes = True
settings.Encoding = Encoding.UTF8
settings.CloseOutput = False
Response.ContentType = "text/xml"
Using writer As XmlWriter = XmlWriter.Create(Response.OutputStream, settings)
writer.WriteStartDocument()

writer.WriteStartElement("chart")
writer.WriteStartElement("chart_data")

writer.WriteStartElement("row")
writer.WriteElementString("null", nullStr)
writer.WriteElementString("string", day30Str)
writer.WriteElementString("string", day60Str)
writer.WriteElementString("string", day90Str)
writer.WriteElementString("string", dayTotalStr)
writer.WriteEndElement()

writer.WriteStartElement("row")
writer.WriteElementString("string", departmentBackStr)
writer.WriteElementString("number", day30Int)
writer.WriteElementString("number", day60Int)
writer.WriteElementString("number", day90Int)
writer.WriteElementString("number", dayTotalInt)
writer.WriteEndElement()

writer.WriteEndElement()
writer.WriteEndElement()

writer.WriteEndDocument()
writer.Flush()
End Using
End Sub
</script>
May 24 '07 #1
1 1473
try writing your dataset directly after your fill it and see if it does as least that much.

use the WriteXml(Response.Output) overloaded method.

or write it to file WriteXml(@"c:\temp\out.xml")
May 25 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Robson Carvalho Machado | last post: by
5 posts views Thread by Popoxinhxan | last post: by
reply views Thread by Martin | last post: by
12 posts views Thread by Ron Weldy | last post: by
8 posts views Thread by George Meng | last post: by
2 posts views Thread by Adnan Al-Ghourabi | last post: by
4 posts views Thread by Mike Logan | last post: by
5 posts views Thread by vikram | last post: by
111 posts views Thread by Nate | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.