473,718 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Serialize Dataset

I am attempting to generate an XML file based on the contents of a dataset
which contains a parent-child relationship but when I create the output file
all I get is the XML header as shown here:

<?xml version="1.0" encoding="utf-8"?>
<DataSet xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />

I know the dataset and the relationship is OK as I have the dataset bound to
datagrids which are showing the correct data.

The dataset is named "ds1", the relationship is defined as shown below. Does
anyone have an idea of what I am doing wrong here?

Wayne

============= Relationship =============== =====
Dim ShowColumns() As DataColumn

Dim PerfColumns() As DataColumn

ShowColumns = New DataColumn() {ds1.Tables(0). Columns("Region alID"),
ds1.Tables(0).C olumns("SeqNbr" )}

PerfColumns = New DataColumn() {ds1.Tables(1). Columns("Region alID"),
ds1.Tables(1).C olumns("SeqNbr" )}

Dim ShowSetsRel As New DataRelation("S howSets", ShowColumns, PerfColumns)

'Add the Relation to the DataSet

ds1.Relations.A dd(ShowSetsRel)
ShowSetsRel.Nes ted = True
============ XML Output code =============== =
Private Sub SerializeDataSe t(ByVal filename As String)

Dim ser As XmlSerializer = New XmlSerializer(G etType(DataSet) )

Dim writer As TextWriter = New StreamWriter(fi lename)

ser.Serialize(w riter, ShowSets) '<= I've trid the name of the
dataset (ds1) and the Relationship object (ShowSetsRel ) - all give no
output

writer.Close()

End Sub
Nov 12 '05 #1
2 9957
Use DataSet.WriteXm l(stream, XmlWriteMode.Wr iteSchema);

"Wayne Wengert" <wa************ ***@wengert.com > wrote in message
news:um******** ******@TK2MSFTN GP11.phx.gbl...
I am attempting to generate an XML file based on the contents of a dataset
which contains a parent-child relationship but when I create the output file all I get is the XML header as shown here:

<?xml version="1.0" encoding="utf-8"?>
<DataSet xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />

I know the dataset and the relationship is OK as I have the dataset bound to datagrids which are showing the correct data.

The dataset is named "ds1", the relationship is defined as shown below. Does anyone have an idea of what I am doing wrong here?

Wayne

============= Relationship =============== =====
Dim ShowColumns() As DataColumn

Dim PerfColumns() As DataColumn

ShowColumns = New DataColumn() {ds1.Tables(0). Columns("Region alID"),
ds1.Tables(0).C olumns("SeqNbr" )}

PerfColumns = New DataColumn() {ds1.Tables(1). Columns("Region alID"),
ds1.Tables(1).C olumns("SeqNbr" )}

Dim ShowSetsRel As New DataRelation("S howSets", ShowColumns, PerfColumns)

'Add the Relation to the DataSet

ds1.Relations.A dd(ShowSetsRel)
ShowSetsRel.Nes ted = True
============ XML Output code =============== =
Private Sub SerializeDataSe t(ByVal filename As String)

Dim ser As XmlSerializer = New XmlSerializer(G etType(DataSet) )

Dim writer As TextWriter = New StreamWriter(fi lename)

ser.Serialize(w riter, ShowSets) '<= I've trid the name of the
dataset (ds1) and the Relationship object (ShowSetsRel ) - all give no
output

writer.Close()

End Sub

Nov 12 '05 #2
Chris;

Thanks for the response but I am having a problem using that code. "stream"
is flagged as "Stream is a type and cannot be used as an expression" ?

Wayne

"Chris Lovett" <cl*****@micros oft.com.no_spam > wrote in message
news:ul******** *****@tk2msftng p13.phx.gbl...
Use DataSet.WriteXm l(stream, XmlWriteMode.Wr iteSchema);

"Wayne Wengert" <wa************ ***@wengert.com > wrote in message
news:um******** ******@TK2MSFTN GP11.phx.gbl...
I am attempting to generate an XML file based on the contents of a dataset which contains a parent-child relationship but when I create the output file
all I get is the XML header as shown here:

<?xml version="1.0" encoding="utf-8"?>
<DataSet xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />

I know the dataset and the relationship is OK as I have the dataset bound to
datagrids which are showing the correct data.

The dataset is named "ds1", the relationship is defined as shown below.

Does
anyone have an idea of what I am doing wrong here?

Wayne

============= Relationship =============== =====
Dim ShowColumns() As DataColumn

Dim PerfColumns() As DataColumn

ShowColumns = New DataColumn() {ds1.Tables(0). Columns("Region alID"),
ds1.Tables(0).C olumns("SeqNbr" )}

PerfColumns = New DataColumn() {ds1.Tables(1). Columns("Region alID"),
ds1.Tables(1).C olumns("SeqNbr" )}

Dim ShowSetsRel As New DataRelation("S howSets", ShowColumns,

PerfColumns)
'Add the Relation to the DataSet

ds1.Relations.A dd(ShowSetsRel)
ShowSetsRel.Nes ted = True
============ XML Output code =============== =
Private Sub SerializeDataSe t(ByVal filename As String)

Dim ser As XmlSerializer = New XmlSerializer(G etType(DataSet) )

Dim writer As TextWriter = New StreamWriter(fi lename)

ser.Serialize(w riter, ShowSets) '<= I've trid the name of the
dataset (ds1) and the Relationship object (ShowSetsRel ) - all give no
output

writer.Close()

End Sub


Nov 12 '05 #3

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

Similar topics

1
1493
by: ofer | last post by:
Hi, I am working with the beta version of the new .net framework (Whidbey) and I encountered a problem with serialization that did'nt exist in the .net 2003 the situation is like this : I have a class that inherits from dataset, and I want to serialize it , so I created a serialization constructor that forwards the call to the base class (the dataset) serialization constructor, normally, for this action to succeed I am supposed to put...
0
1367
by: IMS.Rushikesh | last post by:
Hi All, I want to serialize an object which contain the DataTable. As DataSet is MarshalByRef object and is serializable. I am using it directly. Even my data is also serialize and save it to XML file. Now as DataSet serialize, it's creating some extra information (schema information), And i don't need that. I only want to store the data in XML format. I don't want to store extra details like namespace etc... As it's increase XML file...
2
8642
by: Marty McDonald | last post by:
I have an array of objects (my own custom class). I'm trying to convert that array to a dataset. So I serialize the array to XML, then try to load the XML to a dataset. MemoryStream mem = new MemoryStream(); XmlTextWriter w = new XmlTextWriter(mem,System.Text.Encoding.UTF8); ser.Serialize(w,books); XmlTextReader r = new XmlTextReader(mem); DataSet dsBooks = new DataSet(); dsBooks.ReadXml(r); <=== error here
4
8707
by: hs | last post by:
Hi I am serializing a dataset using a binary formatter as follows: IFormatter formater = new BinaryFormatter(); formatter.Serialize(stream, ds); // ds=DataSet, stream=MemoryStream .... DataSet ds2 = (DataSet)formatter2.Deserialize(stream2); For the size of my DataSet, its taking 0.8 seconds to serialize and 2.3 seconds to deserialize.
2
2354
by: ofer | last post by:
Hi, I am working with the beta version of the new .net framework (Whidbey) and I encountered a problem with serialization that did'nt exist in the .net 2003 the situation is like this : I have a class that inherits from dataset, and I want to serialize it , so I created a serialization constructor that forwards the call to the base class (the dataset) serialization constructor, normally, for this action to succeed I am supposed to put...
4
7484
by: Brian Keating | last post by:
wonder if anyone can help me here, i've a framework 1.1 dataset which i serialize in framework 1.1 and deserialize in framework 2.0. This is fine, problem is that i want to modify some of the records in framework 2.0 and serialize the data so framework 1.1 can deserialize it and do what it required. Is this possible?
1
5551
by: J. Askey | last post by:
I am implementing a web service and thought it may be a good idea to return a more complex class (which I have called 'ServiceResponse') in order to wrap the original return value along with two other properties... bool error; string lastError; My whole class looks like this... using System;
4
9572
by: Abi | last post by:
We able to generate this error in our test environment and were able to research this enough to understand that the issue is NOT with an abject that needs to be serialized but rather as the stack trace suggests that the server (in the web farm) ran out of memory while attempting to stream data to an ASP Session State database (SQL Server 2000) . Our test environment consists of: - 3 web servers Load Balanced - SQL Server 2000 Database...
6
1577
by: Paez | last post by:
Hello there. My teacher asked me to do a job and I don't know how.. This is the scenario: I must create a client/server application. The server application is a c# web server and the client is a c# windows aplication. The web service will connect with a access database.
0
8723
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9354
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9207
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9053
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7987
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6652
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4481
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4741
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2553
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.