Baffled by XML <-> Dataset

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,
 
D

David Keenan

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
 
K

Kathleen Dollard

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.
 

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