473,398 Members | 2,427 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

dataset as xml to client

I have an aspx page that reads info from a database and puts in in a
dataset. Then an XML-file is created by a myDataset.WriteXml("myInfo.xml")
statement.

After that the XML-file must be read by an aspx-page that resides on
anaother server. I do that as follows
Dim reader as XmlTextReader = New
XmlTextReader("http://companywebsite.nl/myInfo.xml").

Then I put the info in a dataset:
Dim ds as DataSet = New DataSet()
ds.ReadXml(reader)

And then the processing continues on my local webserver.

I would like to make a page that don't writes the xml to a file but that
sends it directly to the calling client. I fact I want to call an
aspx-pages that creates the xml and sends it direct to the calling page,
like
Dim reader as XmlTextReader = New
XmlTextReader("http://companywebsite.nl/GiveMeMyInfo.aspx")

The trick is i call an aspx-page but want xml back, can anybody tell me how
to do that?

John
Nov 18 '05 #1
4 1085
Hi John,

Here's some code that should point the way. Just put this in an .aspx page
with no other content (no HTML at all) and execute it.

<%@ Page Language="vb" AutoEventWireup="true"%>
<script language=vb runat=server>
Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
' By Ken Cox for John Boers
' July 18/2004
Dim myDataSet As New system.data.DataSet
myDataSet.Tables.Add(CreateDataSource())
Dim xmlDoc As System.Xml.XmlDataDocument = _
New System.Xml.XmlDataDocument(myDataSet)
Response.Clear()
Response.ClearHeaders()
Response.ContentType = "text/xml"
Response.Write(xmlDoc.InnerXml)
End Sub
Function CreateDataSource() As _
system.data.DataTable
Dim dt As New system.data.DataTable
Dim dr As system.data.DataRow
dt.Columns.Add(New system.data.DataColumn _
("IntegerValue", GetType(Int32)))
dt.Columns.Add(New system.data.DataColumn _
("StringValue", GetType(String)))
dt.Columns.Add(New system.data.DataColumn _
("CurrencyValue", GetType(Double)))
dt.Columns.Add(New system.data.DataColumn _
("Boolean", GetType(Boolean)))
Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()
dr(0) = i
dr(1) = "Item " + i.ToString()
dr(2) = 1.23 * (i + 1)
dr(3) = (i = 4)
dt.Rows.Add(dr)
Next i
Return dt
End Function 'CreateDataSource
</script>
Does this help?

Ken
Microsoft MVP [ASP.NET]
Toronto
"John Boers" <jj******@hccnet.nl> wrote in message
news:di*****************************@40tude.net...
I have an aspx page that reads info from a database and puts in in a
dataset. Then an XML-file is created by a myDataset.WriteXml("myInfo.xml")
statement.

After that the XML-file must be read by an aspx-page that resides on
anaother server. I do that as follows
Dim reader as XmlTextReader = New
XmlTextReader("http://companywebsite.nl/myInfo.xml").

Then I put the info in a dataset:
Dim ds as DataSet = New DataSet()
ds.ReadXml(reader)

And then the processing continues on my local webserver.

I would like to make a page that don't writes the xml to a file but that
sends it directly to the calling client. I fact I want to call an
aspx-pages that creates the xml and sends it direct to the calling page,
like
Dim reader as XmlTextReader = New
XmlTextReader("http://companywebsite.nl/GiveMeMyInfo.aspx")

The trick is i call an aspx-page but want xml back, can anybody tell me
how
to do that?

John


Nov 18 '05 #2
On Sun, 18 Jul 2004 10:00:12 -0400, Ken Cox [Microsoft MVP] wrote:
Hi John,

Here's some code that should point the way. Just put this in an .aspx page
with no other content (no HTML at all) and execute it.

<%@ Page Language="vb" AutoEventWireup="true"%>
<script language=vb runat=server>
Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
' By Ken Cox for John Boers
' July 18/2004
Dim myDataSet As New system.data.DataSet
myDataSet.Tables.Add(CreateDataSource())
Dim xmlDoc As System.Xml.XmlDataDocument = _
New System.Xml.XmlDataDocument(myDataSet)
Response.Clear()
Response.ClearHeaders()
Response.ContentType = "text/xml"
Response.Write(xmlDoc.InnerXml)
End Sub
Function CreateDataSource() As _
system.data.DataTable
Dim dt As New system.data.DataTable
Dim dr As system.data.DataRow
dt.Columns.Add(New system.data.DataColumn _
("IntegerValue", GetType(Int32)))
dt.Columns.Add(New system.data.DataColumn _
("StringValue", GetType(String)))
dt.Columns.Add(New system.data.DataColumn _
("CurrencyValue", GetType(Double)))
dt.Columns.Add(New system.data.DataColumn _
("Boolean", GetType(Boolean)))
Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()
dr(0) = i
dr(1) = "Item " + i.ToString()
dr(2) = 1.23 * (i + 1)
dr(3) = (i = 4)
dt.Rows.Add(dr)
Next i
Return dt
End Function 'CreateDataSource
</script>
Does this help?

Ken
Microsoft MVP [ASP.NET]
Toronto
"John Boers" <jj******@hccnet.nl> wrote in message
news:di*****************************@40tude.net...
I have an aspx page that reads info from a database and puts in in a
dataset. Then an XML-file is created by a myDataset.WriteXml("myInfo.xml")
statement.

After that the XML-file must be read by an aspx-page that resides on
anaother server. I do that as follows
Dim reader as XmlTextReader = New
XmlTextReader("http://companywebsite.nl/myInfo.xml").

Then I put the info in a dataset:
Dim ds as DataSet = New DataSet()
ds.ReadXml(reader)

And then the processing continues on my local webserver.

I would like to make a page that don't writes the xml to a file but that
sends it directly to the calling client. I fact I want to call an
aspx-pages that creates the xml and sends it direct to the calling page,
like
Dim reader as XmlTextReader = New
XmlTextReader("http://companywebsite.nl/GiveMeMyInfo.aspx")

The trick is i call an aspx-page but want xml back, can anybody tell me
how
to do that?

John


Hello Ken,

I just tested your example, it works great. I never thought about the
content-type option.

Thanks,

John
Nov 18 '05 #3
Hello Ken,

I implemented your solution in my application and it is workin great.

I am now really sharing information between a global and a local server.
The combination of ASP.NET and XML proves to be very powerfull.

Thanks again,

John
On Sun, 18 Jul 2004 10:00:12 -0400, Ken Cox [Microsoft MVP] wrote:
Hi John,

Here's some code that should point the way. Just put this in an .aspx page
with no other content (no HTML at all) and execute it.

<%@ Page Language="vb" AutoEventWireup="true"%>
<script language=vb runat=server>
Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
' By Ken Cox for John Boers
' July 18/2004
Dim myDataSet As New system.data.DataSet
myDataSet.Tables.Add(CreateDataSource())
Dim xmlDoc As System.Xml.XmlDataDocument = _
New System.Xml.XmlDataDocument(myDataSet)
Response.Clear()
Response.ClearHeaders()
Response.ContentType = "text/xml"
Response.Write(xmlDoc.InnerXml)
End Sub
Function CreateDataSource() As _
system.data.DataTable
Dim dt As New system.data.DataTable
Dim dr As system.data.DataRow
dt.Columns.Add(New system.data.DataColumn _
("IntegerValue", GetType(Int32)))
dt.Columns.Add(New system.data.DataColumn _
("StringValue", GetType(String)))
dt.Columns.Add(New system.data.DataColumn _
("CurrencyValue", GetType(Double)))
dt.Columns.Add(New system.data.DataColumn _
("Boolean", GetType(Boolean)))
Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()
dr(0) = i
dr(1) = "Item " + i.ToString()
dr(2) = 1.23 * (i + 1)
dr(3) = (i = 4)
dt.Rows.Add(dr)
Next i
Return dt
End Function 'CreateDataSource
</script>
Does this help?

Ken
Microsoft MVP [ASP.NET]
Toronto
"John Boers" <jj******@hccnet.nl> wrote in message
news:di*****************************@40tude.net...
I have an aspx page that reads info from a database and puts in in a
dataset. Then an XML-file is created by a myDataset.WriteXml("myInfo.xml")
statement.

After that the XML-file must be read by an aspx-page that resides on
anaother server. I do that as follows
Dim reader as XmlTextReader = New
XmlTextReader("http://companywebsite.nl/myInfo.xml").

Then I put the info in a dataset:
Dim ds as DataSet = New DataSet()
ds.ReadXml(reader)

And then the processing continues on my local webserver.

I would like to make a page that don't writes the xml to a file but that
sends it directly to the calling client. I fact I want to call an
aspx-pages that creates the xml and sends it direct to the calling page,
like
Dim reader as XmlTextReader = New
XmlTextReader("http://companywebsite.nl/GiveMeMyInfo.aspx")

The trick is i call an aspx-page but want xml back, can anybody tell me
how
to do that?

John

Nov 18 '05 #4
Hi John,

Thanks for reporting back!

It is nice to know when something solves a problem - and I'm sure future
Googlers will appreciate knowing too!

Ken

"John Boers" <jj******@hccnet.nl> wrote in message
news:qb*****************************@40tude.net...
Hello Ken,

I implemented your solution in my application and it is workin great.

I am now really sharing information between a global and a local server.
The combination of ASP.NET and XML proves to be very powerfull.

Thanks again,

John
On Sun, 18 Jul 2004 10:00:12 -0400, Ken Cox [Microsoft MVP] wrote:
Hi John,

Here's some code that should point the way. Just put this in an .aspx
page
with no other content (no HTML at all) and execute it.

<%@ Page Language="vb" AutoEventWireup="true"%>
<script language=vb runat=server>
Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
' By Ken Cox for John Boers
' July 18/2004
Dim myDataSet As New system.data.DataSet
myDataSet.Tables.Add(CreateDataSource())
Dim xmlDoc As System.Xml.XmlDataDocument = _
New System.Xml.XmlDataDocument(myDataSet)
Response.Clear()
Response.ClearHeaders()
Response.ContentType = "text/xml"
Response.Write(xmlDoc.InnerXml)
End Sub
Function CreateDataSource() As _
system.data.DataTable
Dim dt As New system.data.DataTable
Dim dr As system.data.DataRow
dt.Columns.Add(New system.data.DataColumn _
("IntegerValue", GetType(Int32)))
dt.Columns.Add(New system.data.DataColumn _
("StringValue", GetType(String)))
dt.Columns.Add(New system.data.DataColumn _
("CurrencyValue", GetType(Double)))
dt.Columns.Add(New system.data.DataColumn _
("Boolean", GetType(Boolean)))
Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()
dr(0) = i
dr(1) = "Item " + i.ToString()
dr(2) = 1.23 * (i + 1)
dr(3) = (i = 4)
dt.Rows.Add(dr)
Next i
Return dt
End Function 'CreateDataSource
</script>
Does this help?

Ken
Microsoft MVP [ASP.NET]
Toronto
"John Boers" <jj******@hccnet.nl> wrote in message
news:di*****************************@40tude.net...
I have an aspx page that reads info from a database and puts in in a
dataset. Then an XML-file is created by a
myDataset.WriteXml("myInfo.xml")
statement.

After that the XML-file must be read by an aspx-page that resides on
anaother server. I do that as follows
Dim reader as XmlTextReader = New
XmlTextReader("http://companywebsite.nl/myInfo.xml").

Then I put the info in a dataset:
Dim ds as DataSet = New DataSet()
ds.ReadXml(reader)

And then the processing continues on my local webserver.

I would like to make a page that don't writes the xml to a file but that
sends it directly to the calling client. I fact I want to call an
aspx-pages that creates the xml and sends it direct to the calling page,
like
Dim reader as XmlTextReader = New
XmlTextReader("http://companywebsite.nl/GiveMeMyInfo.aspx")

The trick is i call an aspx-page but want xml back, can anybody tell me
how
to do that?

John


Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Programatix | last post by:
Hi, I'm working on a project which includes XML WebServices and Windows Form application. The Windows Form application will call the XML WebServices to retrieve data from database. The data...
7
by: Richard Myers | last post by:
Hello. I am getting an InvalidCastException which has revealed yet more of my ignorance. I cant believe i dont already know this and haven't encountered it before until now. I am consuming a...
1
by: Andy | last post by:
Hello, I have a WebService that sends a client a DataSet as XML (I use a DataSet.GetXml to get the XML). The DataSet is filled by a DataAdapter in the WebService. The client coverts the XML Back...
10
by: localhost | last post by:
I have a static, thread-safe class with a DataSet as a property. When the class is instanced into an object, some callers add rows to a DataTable in the DataSet. Other callers read the DataSet. ...
2
by: Martin | last post by:
Hi! I'm new to ASP.NET WebApplications and wonder whether I've missed something out when programming it. I'm grateful for any hints to this problem! Thanks very much for your efforts! Martin...
22
by: Arne | last post by:
How do I pass a dataset to a webservices? I need to submit a shoppingcart from a pocket PC to a webservice. What is the right datatype? II have tried dataset as a datatype, but I can't get it to...
2
by: Anthony Malt | last post by:
Hi, my server has a database table. I read this table on the server into a dataset and my client retrieves it through a webservice. No changes on the client and server happen. What's the best...
4
by: Al | last post by:
I have this scenario: 1. XML file with schema and data is created from SQL Server tables. XML file contains 6 tables, some of them have rows, some of them are empty. 2. XML file is given to the...
3
by: Jon Vaughan | last post by:
I have a client side dataset that is made up from a stored proc, I also have a web service that returns a dataset from this stored proc. But when I call the web service and try and store them in an...
15
by: Joseph Geretz | last post by:
I'm a bit puzzled by the current recommendation not to send Datasets or Datatables between application tiers. http://support.microsoft.com/kb/306134 ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.