1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

DataTable does not match to any DataTable in source

Discussion in 'C#' started by GunnarJ, Aug 28, 2010.

  1. GunnarJ

    GunnarJ New Member

    Joined:
    Aug 28, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Trying to create a program to read from an XML file and put the data into a DataTable inside of a DataSet. The problem I am facing at the moment is that I keep getting the error "DataTable 'baseDataTable' does not match any DataTable in source". Here is my code (all made active by button press).

    Main form:

    Code:
    FileStream fs = new FileStream("NPCBase.xml", FileMode.Open, FileAccess.Read);
    DataSet baseDataSet = new DataSet("baseDataSet");
    DataTable baseDataTable = new DataTable("baseDataTable");
    baseDataSet.Tables.Add(baseDataTable);
    baseDataSet.Tables["baseDataTable"].ReadXmlSchema("NPCBase.xsd");
    baseDataSet.Tables["baseDataTable"].ReadXml("NPCBase.xml");
    dataGridView1.DataSource = baseDataSet;
    dataGridView1.DataMember = "baseDataTable";
    NPCList.xml:

    Code:






    Guy#1




    Guy#2




    Schema:

    Code:
     

Share This Page