Click here to Skip to main content
13,259,847 members (46,400 online)
Rate this:
Please Sign up or sign in to 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"];

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

and it points to the following line

Posted 26-Jul-10 5:37am
Updated 26-Jul-10 5:57am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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

Solution 2

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:

DataTable tbldt;
tbldt = xmlDatadocTimeTable.DataSet.Tables["TIMETABLES"];
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.171114.1 | Last Updated 3 Aug 2010
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