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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML Formatting from SQL Server data

Status
Not open for further replies.

ietprofessional

Programmer
Apr 1, 2004
267
US
I posted a question concerning this topic before, hopefully this post will get more attention.

I'm pulling some data from a sql server, and with C# I'm converting the data to XML. Some of my data are money values, and when I convert the xml to html with a xslt file I'm getting values like 5.0000 instead of 5.00.

Has anyone had this problem? Does anyone know how to resolve it?

Thanks,
Harold
 
Just a question -

Why convert SQL data to XML in C# when there's built-in functionality to do it in SQL?

Renders XML inline:
Code:
SELECT * FROM [table]
FOR XML AUTO

Renders XML as broken-up elements:
Code:
SELECT * FROM [table]
FROM XML AUTO, ELEMENTS

Hope that helps make your life easier :)

-----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
 
AtomicChip -

One reason to do it through code in the middle tier is to minimize the load on the database server. Telling the database convert to XML via "FOR XML AUTO" uses a lot of CPU which could be better spent on retrieving rows.

ietprofessional -
Are you using an XSD anywhere? My thought is that if you have an element defined as being a floating-point type, the XSLT processor may be padding your value.

In any case, it may not matter -- if you take that value and when you read it from your Document store it in a floating-point datatype native to your language (float or double), the excess precision will be dropped.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
I'm not using xsd. Can you give me a good resource for it and how I can implement it in to my project?

Thanks,
Harold
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top