Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I have created some XML data viz: Sales_Details.xml now I want to transfer such data on a dataGridview control. I have written code for that problem but it shows an error like "cannot find table 0". I don't understand why the error is appearing.


private void button1_Click(object sender, EventArgs e)
        {
            XmlTextReader tr = new XmlTextReader("E:\\Sales_Details.xml");
            DataSet ds = new DataSet();
            ds.ReadXml(tr);
            dataGridView1.DataSource = ds.Tables[0].DefaultView;
        }
Posted
Updated 5-Feb-13 3:48am
v2

The error indicates that in the dataset no datatable is created, hence tables[0] is throwing an exception.

You can go through the following link on how to read data from xml.
http://msdn.microsoft.com/en-us/library/c7xcc35f.aspx[^]
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900