tags:

views:

307

answers:

5

I need to compare the table structure of two datasets to check for any discrepencies, is this possible?

I had though of converting to XML and comparing but is there a better way?

Thanks

A: 

You could convert to XML and compare, but that has code smell to me. You could either use LINQ (if you're using .NET 3.5) or just manually loop through your tables, columns, and rows and see if there are any differences.

Adam Robinson
A: 

Converting to two XML files does look like an option.

You can use a Diffgram to so the comparision.

DiffGram

(First para from MSDN link)

A DiffGram is an XML format that identifies current and original versions of data elements. The DataSet uses the DiffGram format to load and persist its contents, and to serialize its contents for transport across a network connection. When a DataSet is written as a DiffGram, it populates the DiffGram with all the necessary information to accurately recreate the contents, though not the schema, of the DataSet, including column values from both the Original and Current row versions, row error information, and row order.

kevchadders
A: 

I think it highly depends on what you want to do. If you want to just visualize the differences then I would go with XML and a difference viewer tool.

If you want to see if they are different and maybe display a short list of changed fields (all this inside an app) then you could also go with an XML representation of schema or do as Adams Robinson mentioned. Basically, no matter how you do it, you'll still have to loop through tables and fields, so you could just as well access them directly and not by transforming them first to XML

rslite
A: 

I would simply use the GetXmlSchema() method on each Dataset and obtain the schema structure as a string. Then both strings can be compared.

Cerebrus
A: 

Just wrote the schema to xml and compared the documents.

Thanks for your help

Rigobert Song