ReadXml fails please help

R

Rainer Queck

Hello NG,

I am using a typed DataSet, created with VS dataset designer.
I have the problem , that a table in the dataset refuses to read a xml file.
The strange thing is that if I create a seperate datatable, using the Typed
DataSet.Table this reads the xml file without any problems:

To make it a little more clear:
public class MyClass
{
....
DsMyDataSet myDataSet; // gets initalized in the constructor

....... some when at runtime this method is called ....
void MyReadFromFile(fileName)
{
myDataSet.myTable.ReadXml(fileName); // fails to read the xml
fail, table has 0 columns
DsMyDataSet.myTableTable tbl = new DsMyDataSet.myTableTable tbl();
tbl.ReadXml(fileName); // works fine, that table holds a bunch of
rows.
}
}

PLEASE HELP. What is it that I am doing wrong?

Regards
Rainer Queck
 
S

sloan

I would start by removing any constraints .. like "primary key"
ones....while you're in the dataset designer.

And when you find the magic constraint that is killing you..you can figure
out your plan of attack for it.

This is a total guess.....please look at others who post ideas as well.
 
R

Rainer Queck

Hello Sloan,

thanks for responding!

sloan said:
I would start by removing any constraints .. like "primary key"
ones....while you're in the dataset designer.

And when you find the magic constraint that is killing you..you can figure
out your plan of attack for it.
The table now has no more constraints. Still the same problem.

Regards
Rainer
 
S

sloan

Then I would try ... throwing some dummy data into one of your strong ds...
And do a WriteXml ("C:\myfile.xml")

and open your original problematic xml and this version, and look for any
differences.

(Again, a total guess).


MyEmployeeDS ds = new MyEmployeeDS();
ds.Employee.AddNewEmployeeRow ( 123, "Smith", "John" );
ds.WriteXml ( "C:\myfile.xml");


something like that. of course your ds name...and tables will be different,
but you get the idea.


My last advice would be to dump the designer....and create a dataset from
scratch..and manually add the tables and columns in the tables.
Long and tedious...but just throwing ideas at you.
 
S

sloan

//quote
"and open your"
//end quote

What I meant by this is:......open both files in notepad, and look for
subtle differences.
 
R

Rainer Queck

Hi Sloan,

thank you very much for your help.

Then I would try ... throwing some dummy data into one of your strong
ds...
And do a WriteXml ("C:\myfile.xml")

and open your original problematic xml and this version, and look for any
differences.
That brought light to the problem.
The original xml had no <Dataset Tag> :
<?xml version="1.0" standalone="yes"?>
<DsVersuchsreihe xmlns="http://tempuri.org/DsVersuchsreihe.xsd"> <=== was
not in the original xml
<tblSollKollektiv>
...
</tblSollKollektiv>
</DsVersuchsreihe> <=== was not in the original xml

That is why the table instance could read it and the dataset.table instance
not.
As I added that <<Dataset Tag> I was able to read the xml.

Puh! Big releave ;-)

Regards
Rainer
 
S

sloan

Sehr Gut!

Notepad spielt nicht harum.

That's a bad translation for

"Notepad doesn't play around".
 

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

Top