ADO.NET 2.0 Dataset based on XML schema file

G

Guest

Hi, I'm trying to use a typed DataSet based on an XML schema file. Here is a
sample XML schema file for a "Location" with four typed-defined elements:

<xs:element name="Document1">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Location">
<xs:complexType>
<xs:sequence>
<xs:element name="Name" type="xs:string" minOccurs="0" />
<xs:element name="Address" type="xs:string" minOccurs="0" />
<xs:element name="Phone" type="xs:string" minOccurs="0" />
<xs:element name="Active" type="xs:boolean" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>

Now, I'd like to create a DataSet based on this file. In the Dataset
Designer, I would like to see a DataTable called "Location" with the four
specified DataColumns.

I know I can do this at run-time by calling XML methods of the DataSet but
how can I define the schema at design time?

Any thoughts are appreciated!
 
G

Guest

Thanks. I guess Copy&Paste IS a great technology. That worked fine. Any
ideas if MS is planning to allow an XML Data Source at some point? Seems
very useful. As a follow-up, will I need to write explicit code to update
the XML file element for each RowStateChanged in my data table? I'm not
planning to insert records but definitely do updates. Apparently, I can't
use a DataAdapter to update, correct? Is there a best practice for the
workaround.

Again, thanks for your response. I've read previous posts you've submitted
and they are always very helpful.
 
S

Sahil Malik [MVP C#]

Thanks. I guess Copy&Paste IS a great technology. That worked fine.

Yeah I wonder who invented it :)
Any
ideas if MS is planning to allow an XML Data Source at some point? Seems
very useful.

There is an XmlDataSource in .NET 2.0.
As a follow-up, will I need to write explicit code to update
the XML file element for each RowStateChanged in my data table?

I didn't understand the Question. :-(
Again, thanks for your response. I've read previous posts you've
submitted
and they are always very helpful.

Cool thanks :)

- Sahil Malik [MVP]
ADO.NET 2.0 book -
http://codebetter.com/blogs/sahil.malik/archive/2005/05/13/63199.aspx
__________________________________________________________
 
G

Guest

There is an XmlDataSource in .NET 2.0.

From MSDN articles, it looks like this is ASP.NET 2.0 only? Here is what I
have - a WinForms app that stores application settings. I have a Windows
Form and a DataSet. I'm dragging columns from DataTables via the Data
Sources window onto my form to create bound controls. I have no trouble
making all this work if my DataSet has a connection string to a database.
However, I'd like to read and update my values with an XML file. The
application settings aren't relational data and I don't need the overhead of
a database. Does this explain where I see a missing link?

I can create my XML schema file and copy the XML into the dataset object -
this creates my individual datatables. Then, I see the dataset in Data
Sources and can pull controls to the form. If my backend was a database, I
could call the Fill method of a TableAdapter/ DataAdapter and get the
contents of the database table into my dataset. At this point, I can't do
something similar to read the elements from an XML file (that conforms to the
same schema as my dataset). Is that the rub? Wouldn't the relationship of a
typed dataset and an object instantiated on that class in my code be similar
to an XML schema file and the XML file that uses that schema?

If I have a typed dataset, it seems like it would be helpful to make the
"data store" an XML file based on the same schema. Does that explain my
question in more detail? The Data Source Configuration Wizard lists
Database, Web Service and Object. Do I consider an object wrapper around an
XML file that could be used by the Wizard or am I just getting deeper and
deeper into the woods?

(I haven't explored the ASP.NET possibilities)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top