Search
Sign In
Home
Recent
Media
Videos
Podcasts
Screencasts
Learn
Shows
10-4
Going Deep
The Id Element
See All Shows...
Forums
Coffeehouse
Tech Off
Feedback
Sandbox
Key Topics
Visual Studio
Continuum
Identity
Interoperability
Azure
Windows
Wiki
Search
Subscribe
Forums
>
Tech Off
Typed DataSets and XML sources
Posted By:
W3bbo
|
Nov 27th, 2008 @ 6:30 AM
page 1 of 1
Comments: 3 | Views: 624
Delete
Edit
Reply
#Nov 27th, 2008 @ 6:30 AM
W3bbo
The Master of Baiters
In reply to {0}
Download:
[Pending]
I've written an XML Schema (*.xsd) file by hand to define an XML file format I'm going to use to store some structured data in. After hearing good things about Typed DataSets working with XML files I used the xsd.exe program to create a DataSet from my XSD.
The thing is... it doesn't seem to work at all.
I've got a regular DataSet and my typed DataSet ("MyDataSet") , both reading data from the same XML file.
...yet it doesn't seem to work:
DataSet ds = new DataSet();
ds.ReadXml ( packageExamplePath );
System.Console.WriteLine( ds.Tables["extra"].Rows.Count ); // prints 19
MyDataSet st = new MyDataSet();
st.ReadXml( packageExamplePath );
System.Console.WriteLine( st.Tables["extra"].Rows.Count ); // prints 0
Am I missing something important? Do I need to include a reference to the XML schema namespace in the source data XML document or something? I've read MSDN but couldn't find anything relevant.
Delete
Edit
Reply
#Nov 27th, 2008 @ 6:35 AM
jh71283
Throw new System.Beverage. OutOfCoffeeException()
In reply to {0}
Download:
[Pending]
For the typed dataset to read the xml, The root node must match the name of your dataset.
I assume your dataset starts with <DataSet> whereas it should be <MyDataSet> for the typed one to read it.
NB. It's case sensitive, too.
Delete
Edit
Reply
#Nov 27th, 2008 @ 10:56 AM
W3bbo
The Master of Baiters
In reply to jh71283
#Nov 27th, 2008 @ 6:35 AM
Download:
[Pending]
The XML file starts off with:
<package>
My constructor for my dataset class looks like:
public Package() : base("package") {
this.BeginInit();
this.InitClass();
CollectionChangeEventHandler schemaChangedHandler = new CollectionChangeEventHandler(this.SchemaChanged);
base.Tables.CollectionChanged += schemaChangedHandler;
base.Relations.CollectionChanged += schemaChangedHandler;
EndInit();
}
Still doesn't work though.
Delete
Edit
Reply
#Nov 27th, 2008 @ 11:50 PM
jh71283
Throw new System.Beverage. OutOfCoffeeException()
In reply to W3bbo
#Nov 27th, 2008 @ 10:56 AM
Download:
[Pending]
try manually putting some records in, and then call GetXML so you can compare the XML you give to the XML it expects.
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
Delete
Edit
Reply
In reply to {0}
Download:
[Pending]
page 1 of 1
Comments: 3 | Views: 624
Forums
>
Tech Off
>
Typed DataSets and XML sources
Be the first to comment!
Reply
Reply to root
In reply to {0}
Start related discussion
Forum:
Site Feedback
Tech Off
The 9 Guy Around The World
The Coffeehouse
Subject:
Tags
*Loading available tags