Click here to Skip to main content
15,891,248 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Good Day ,

It has been a long day. here we go
tbldt = new DataTable("TIMETABLES");
       XmlDataDocument xmlDatadocTimeTable = new XmlDataDocument();
       xmlDatadocTimeTable.DataSet.ReadXml(@"C:\Pilot Project\App_Data\TimeTable_Full.xml");
       tbldt = (DataTable)xmlDatadocTimeTable.DataSet.Tables["TIMETABLES"];
       dsFinalTimeTable.Tables.Add(tbldt);

and the Error is:
table' argument cannot be null. Parameter name: table

and it points to the following line
dsFinalTimeTable.Tables.Add(tbldt);


Thanks
Posted
Updated 26-Jul-10 4:57am
v2

The new instance of the datatable set into "tbldt" is being reset by the line:

tbldt = (DataTable)xmlDatadocTimeTable.DataSet.Tables["TIMETABLES"];
I would check to make sure your file "TimeTable_Full.xml" indeed has the TIMETABLES table. Because it seems, it does not.
 
Share this answer
 
I agree with Andrew.

As a side note, you're wasting memory by declaring tbldt equal to a new DataTable.

You then change where tbldt is pointing to without disposing of the other table which AFAIK will keep the new DataTable in memory and you'll not be able to use that block.

Since you're setting tbldt to a DataTable, you don't need to create it as a new object. You also don't need to tell it that it is a DataTable. DataSet.Tables[stringValue] returns a DataTable; This is the way to do it:

C#
DataTable tbldt;
tbldt = xmlDatadocTimeTable.DataSet.Tables["TIMETABLES"];
 
Share this answer
 
Comments
koool.kabeer 27-Jul-10 2:26am    
Exactly Perfect 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