Can I change to field type in an XML schema automatically?

  • Thread starter Thread starter jamie
  • Start date Start date
J

jamie

I have built an XML file using the DataSet.writeXML method and it creates
this schema

<?xml version="1.0" standalone="yes"?>
<LengthConversion>
<xs:schema id="LengthConversion" xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="LengthConversion" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="lengthConversion">
<xs:complexType>
<xs:sequence>
<xs:element name="METERS" type="xs:double" minOccurs="0" />
<xs:element name="FEET1" type="xs:int" minOccurs="0" />
<xs:element name="percentage1" type="xs:int" minOccurs="0"
/>
<xs:element name="feet2" type="xs:int" minOccurs="0" />
<xs:element name="percentage2" type="xs:int" minOccurs="0"
/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<lengthConversion>

Now the issue I have is getting the Double into a sqlce database. Double
isn't a valid datatype for sqlce. The original field type is float, I'm
not sure why it's becoming a double in the XML

My question is how to best correct this issue.

Can I specify that it's a float or a string in the XML generated
automatically?

Any other suggestions on how to handle this?

Changing the original database type to be something else isn't an option.

Jamie
 
SQL's "float" matches CLR's double:

http://msdn.microsoft.com/library/d...f/html/frlrfsystemdatasqldbtypeclasstopic.asp

So, SQL column of "float" would be represented as CLR's double in the
DataSet.

Please describe why exactly it's a problem for you.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

*** Want to find answers instantly? Here's how... ***

1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).
 
Getting the data into the dataset on the pocket PC device works fine. The
issue is when I try and write that dataset to the sqlce database using the
SqlCeDataAdapter.Update method. I recieve an exception that just says
System.Data.SqlServerCe.SqlCeException

I've tried cutting down the database and XML to being just the float/double
field and It still fails.
 
You should catch this exception and print out error messages from error
collection to figure out what's wrong.

SqlCeException class description on MSDN has a sample on how to do that.



Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

*** Want to find answers instantly? Here's how... ***

1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).
 
Back
Top