Click here to Skip to main content
13,088,101 members (40,603 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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();
            dataGridView1.DataSource = ds.Tables[0].DefaultView;
Posted 5-Feb-13 3:27am
Updated 5-Feb-13 3:48am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.[^]
Rate this: bad
Please Sign up or sign in to vote.

Solution 2


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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170813.1 | Last Updated 5 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100