Looking for a better way to search & transfer information between DataSets and XmlDataDocuments

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: David Elliott (Webbert_at_newsgroups.nospam)
Date: 06/17/04


Date: Thu, 17 Jun 2004 09:34:38 -0400

I am scraping a database to create a XSD file that will be used to create typed DataSets. In
doing this I am adding a mapping capability to rename the field names from the Database
column name to a user friendly name.

The approach I have taken is to get the schema using DataAdapter.FillSchema() and then
passing it to a XmlDataDocument

        dataAdapter.FillSchema(ds, SchemaType.Source);

        xmlDataDoc = new XmlDataDocument ( );
        xmlDataDoc.LoadXml ( ds.GetXmlSchema() );
        xmlDataDoc.Normalize ( );

After I have the XmlDataDocument, I can use XmlNode.SelectNodes() and
XmlNode.SelectSingleNode() to find particular nodes. And using my map file I can
annotate the node with a new name.

After this is done, I want to have pretty formatting in order to write the schema to disk.
To do this I recreate the DataSet from the XmlDataDocument.

        DataSet ds = new DataSet();
        MemoryStream ms = new MemoryStream ( Encoding.Unicode.GetBytes ( xmlDoc.OuterXml ) );

        ms.Position = 0;
        ds.ReadXmlSchema(ms);

While this works, I was wondering if there is a better way to
        -- Search
        -- Retain Formatting
        -- Access the data in the XmlDataDocument

Any thoughts are appreciated.

Cheers,
Dave



Relevant Pages

  • Re: Update auto generated xsd files manually
    ... I am using VS 2005 to write a C# app that uses an Access Database. ... I edited the xsd file and changed the ... changed connections is an issue. ... connection string. ...
    (microsoft.public.dotnet.framework.adonet)
  • RE: Problem with .xsd datasets
    ... "Previous" steps to reconfigure the database connection string. ... you easily change all DataSet's database name. ... Given that the .xsd file is ...
    (microsoft.public.dotnet.framework.aspnet)
  • Complex queries on Local data objects?
    ... I'm using typed datasets and in my application I, for the most part, ... keep local copies of everything in the database in DataTables. ... or other types of more complicated Sql queries. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Complex queries on Local data objects?
    ... Maybe not the best answer for people using strongly typed datasets, ... keep local copies of everything in the database in DataTables. ... to find any functions in the DataTable and/or DataSet objects either. ... or other types of more complicated Sql queries. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Return a dataset for a multitable query
    ... Dim ta As New Database1DataSetTableAdapters.QueryTestTableAdapter ... You can extend the table adapters with filters on the view that suits your ... right click on the xsd file in the project explorere and choose ... Are you sure about the "strongly" typed datasets and if so, ...
    (microsoft.public.dotnet.languages.vb)