none
create XML file for strongly type Dataset in c# RRS feed

  • Question

  • Hi:

          I had a dataset name as Dataset1 created manually with data designer which is strongly type. as this strongly type Dataset1 is used to generate Graph in Report.

    The scenario is like this:

    If the namespace below is missing

    <Dataset1 Xmlns="http://tempuri.org/Dataset1.xsd">

    the data is not loaded when i used dataset.readxml

    So, how do I add this namespace with xmlwriter or xmldocument when creating a new XML File EACH TIME?

    Thanks

     

     

     



    Davinci Blurr
    Thursday, July 7, 2011 6:55 AM

Answers

  • Some of it might depend on how your Typed DataSet was defined maybe? All I know for sure, is that when I do a DataSet.WriteXml(), I do *NOT* get any namespaces in my XML file. I know you said you designed the .xsd in the DataSet designers, but you still shouldn't need that namespace. I'm not 100% sure how the DataSet Designer does it anymore, since I don't use that Designer for my Typed DataSets. 

    I have a little utility app I posted about in my blog for easily creating an .xsd:

    http://geek-goddess-bonnie.blogspot.com/2010/04/create-xsd.html

    You shouldn't need to specify any additional parameters when reading/writing XML either (don't know if you did or not, but I'm just mentioning it).

    // should be all you need to do
    MyDataSet.WriteXml(MyFileName);
    MyDataSet.ReadXml(MyFileName);
    
    

     


    ~~Bonnie Berent [C# MVP]

    geek-goddess-bonnie.blogspot.com
    Thursday, July 7, 2011 3:45 PM

All replies

  • Hi Davinci,

     

    Is there a particular reason you are building the dataset by "hand"?


    Miha Markic [MVP C#] http://blog.rthand.com
    Thursday, July 7, 2011 2:25 PM
  • It's not clear what you're trying to do. That Xmlns that you showed is not required in your .xsd. Or, are you saying it's in the XML that you're trying read into the Typed DataSet? In which case, that namespace shouldn't be required in that XML data either. Are you reading in XML from a string or from a file? Could you post a bit of relevant code?


    ~~Bonnie Berent [C# MVP]

    geek-goddess-bonnie.blogspot.com
    Thursday, July 7, 2011 3:00 PM
  • Hi Bonnie:

                     I'm actually upgrading and rewrote a old VB6 Program to C#(VS2005), There is a portion of the code that used to stored a lot readout (2 data per row) in text file, these data will be eventually exported to plot graph in Excel. Since VS2005 has the Graph Reporting capability, I preferred to display the graph with Report Viewer and eventually print the graph by the user.

    Correct me if i'm wrong, the Graph features in Report need to be added with fields so I need to provide a data source, So If I use Typed DataSet, by using Dataset.ReadXML, there will be some advantages (in case user need to print all relevant data, these dataset will come in handy) as compare to looping thru Text files.

    I have little experience using XMl file, but i do read a lot about it,  the

    <Dataset1 Xmlns="http://tempuri.org/Dataset1.xsd"> came from "backward" engineering, where i used dataset.writexml to create an output xml file. From here I got the format that I need to read back to the dataset which come with the namespace. Now If I delete the name space, no data will be loaded to the dataset.

    So you are saying the name space is irrelevant ?

     

    Thanks

     

     

     

     


    Davinci Blurr
    Thursday, July 7, 2011 3:26 PM
  • Some of it might depend on how your Typed DataSet was defined maybe? All I know for sure, is that when I do a DataSet.WriteXml(), I do *NOT* get any namespaces in my XML file. I know you said you designed the .xsd in the DataSet designers, but you still shouldn't need that namespace. I'm not 100% sure how the DataSet Designer does it anymore, since I don't use that Designer for my Typed DataSets. 

    I have a little utility app I posted about in my blog for easily creating an .xsd:

    http://geek-goddess-bonnie.blogspot.com/2010/04/create-xsd.html

    You shouldn't need to specify any additional parameters when reading/writing XML either (don't know if you did or not, but I'm just mentioning it).

    // should be all you need to do
    MyDataSet.WriteXml(MyFileName);
    MyDataSet.ReadXml(MyFileName);
    
    

     


    ~~Bonnie Berent [C# MVP]

    geek-goddess-bonnie.blogspot.com
    Thursday, July 7, 2011 3:45 PM