DataTable Serialization Bug ---- DataTypes magically changing?

C

Cip

Hi,

I am having serious problems serializing DataTables and getting them
to preserve their column types.

I have a DataTable with column "AY" having a string, and all other
cols having doubles.

I can successfully save the DataTable to an XML file,
Looking at the XML file I have:
<xs:element name="AY" type="xs:string"
msdata:targetNamespace="" minOccurs="0" />
<xs:element name="C1" type="xs:double"
msdata:targetNamespace="" minOccurs="0" />

and:

<AY>Average</AY>
<C1>2.7678248946098973</C1>



This looks good.

Now my application reloads the DataTable from the XML file to display
it in a grid. Once the user exits the application it is saved ONCE
more to the XML file.

Looking at the XML file this time I have:

<xs:element name="AY" type="xs:int" msdata:targetNamespace=""
minOccurs="0" />
<xs:element name="C1" type="xs:double"
msdata:targetNamespace="" minOccurs="0" />

and:

<AY>Average</AY>
<C1>2.7826404125785742</C1>


Why does it change column AY to an integer?? If I reload the
DataTable I get a System.Reflection.TargetInvocationException

I have successfully traced the problem to the XML file since it is
trying to covert "Average" to an integer when it is reloading the
DataTable.

I have stepped through code in my application and IMMEDIATELY before
the DataTable is saved to the XML file the DataType of Column AY =
System.String.

I have no idea why it changes magically to int.

And this only happens the SECOND time the DataTable is saved. The
first time it is saved it always works as expected.

Is there a bug that I should be aware of?
 
R

Ravi[MSFT]

This should not happen. I'm not able to repro. How are you serializing the
DataTable? If you can send me a sample code to repro the issue you are
mentioning, I can help you out.

Thanks,
Ravi
 

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