Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Typed dataset and ReadXml

Status
Not open for further replies.

d00ape

Programmer
Apr 2, 2003
171
SE
Hi!

I have some problems with my typed dataset, the dataset contains several datatables and the problem occurs when i try to load the dataset with the ReadXml function. The problem is that some of the tables won't load properly. For example:


MyDataSet ds = new MyDataSet;
ds.ReadXml("ds.xml");

The table table1 in ds will be empty, even if the xml-file contains data that belongs to table1.

MyDataSet ds = new MyDataSet;
ds.table1.ReadXml("table1.xml");

Doesnt work either, but this will work:

MyDataSet ds = new MyDataSet;
MyDataSet.table1 tb1 = new MyDataSet.table1();
tb1.ReadXml("table1.xml")
ds.table1.Merge(tb1);


Any ideas what the problem is?

APe
 
Are you getting the DataTable correctly. Your example does not show it that to be true.

Here is how you get a datatable from a dataset.

Code:
DataSet ds = new DataSet();
DataTable dt = ds.Tables[index of table you want]

Example
Code:
DataTable dt = ds.Tables[0] //Returns the first table in the dataset
DataTable dt = ds.Tables[1] //Returns the second table in the dataset
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top