Baffled by XML <-> Dataset

  • Thread starter Thread starter Mat
  • Start date Start date
M

Mat

Help!

I've just started looking into persisting data to SQL 2000 for a .net
application. I have a XML document in the form

<Data>
<Customer>
<ID>1</ID>
<Name>Cust1</Name>
<Address>
<CustId>1</CustId>
<AddressType>1</AddressType>
<Town>A Town</Town>
</Address>
<Address>
<CustId>1</CustId>
<AddressType>2</AddressType>
<Town>A Town</Town>
</Address>
</Customer>
</Data>

Within SQL There are two tables, Customer and Address, which a
relation between both on the CustomerId. CustomerId is a uniqueKey.
If there an easy way to persist the infomation to/from SQL 2000? I've
looked at datasets which are probably the key to the solution (is this
the right track?).


If so, is there anyway of getting the relationship built automatically
within dataset tables, or does this have to be automatic.

Is a dataset with an underlying schema is used, this seems to be
ignored when populating the dataset with the results from the SQL
query.

Can multiple tables /rows be updated within one transaction, as I
don't want to create a network traffic hungry application?

Finally, is there a good WEB site to get this information from? Info
seems a little hard to get on this!

Cheers,
 
Hi Mat,

You could try using an SqlXml UpdateGram to update your
database. Something like the following should do you.

<?xml version="1.0"?>
<YourDataBaseName
xmlns:updg="urn:schemas-microsoft-com:xml-updategram">
<updg:sync>
<updg:before></updg:before>
<updg:after>
<Customer
updg:at-identity="customerID"
Name="Cust1" />
<Address
CustId="customerID"
AddressType="1"
Town="A Town" />
</updg:after>
</updg:sync>
</YourDataBaseName>

You could apply an xslt stylesheet to your xml to
transform it into the format above.

Hope this helps!

Dave
 
Mat,

Can you load the XML into a DataSet? Some you can, and some you can't. Best
to just try it. (ReadXML).
If so, is there anyway of getting the relationship built automatically
within dataset tables, or does this have to be automatic.

You'll probably have to set the relation up yourself. It's just a few lines
of code to add a relation to the DataSet.
Can multiple tables /rows be updated within one transaction, as I
don't want to create a network traffic hungry application?

I think you mean in one database request - so no. If you mean transaction,
then sure.
Finally, is there a good WEB site to get this information from? Info
seems a little hard to get on this!

There are lots of sites. I find .NET has finally taught me to become
competent with Google.
 
Back
Top