Why are these tables not adding

G

Guest

Hi,
I am trying to load 3 xml files into one dataset like

dsXML.ReadXml(Server.MapPath("file1.xml")
dsXML.ReadXml(Server.MapPath("file2.xml"))
dsXML.ReadXml(Server.MapPath("file3.xml"))

I am then trying to display each files in separate datagrid

datagrid1.datasource = dsXml.tables(0)
datagrid1.datasource = dsxml.databind

datagrid2.datasource = dsXml.tables(1).columns(1).toString
datagrid2.datasource = dsxml.databind

datagrid3.datasource = dsXml.tables(2).columns(1).toString
datagrid3.datasource = dsxml.databind

I am getting the error

Cannot find table 1.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.IndexOutOfRangeException: Cannot find table 1.



Is this possible.

Thanks
 
L

Lucas Tam

I am trying to load 3 xml files into one dataset like

dsXML.ReadXml(Server.MapPath("file1.xml")
dsXML.ReadXml(Server.MapPath("file2.xml"))
dsXML.ReadXml(Server.MapPath("file3.xml"))

I am then trying to display each files in separate datagrid

datagrid1.datasource = dsXml.tables(0)
datagrid1.datasource = dsxml.databind

datagrid2.datasource = dsXml.tables(1).columns(1).toString
datagrid2.datasource = dsxml.databind

datagrid3.datasource = dsXml.tables(2).columns(1).toString
datagrid3.datasource = dsxml.databind

I am getting the error

Cannot find table 1.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.IndexOutOfRangeException: Cannot find table
1.

I think you're getting this error because ReadXML only creates 1 Dataset
based on one XML file. It won't create multiple tables for you. You'll
need to explicitly load each table.
 
G

Guest

Hi,
Does that mean I need separate datasets?

Lucas Tam said:
I think you're getting this error because ReadXML only creates 1 Dataset
based on one XML file. It won't create multiple tables for you. You'll
need to explicitly load each table.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top