2012年3月27日星期二

float and money Data conversion between ado com and ado dotnet not the same with sql

I am running the same query through the traditional ado com interface and
through dotnet ado. The query is a FOR XML EXPLICIT and in ado com I am
using the streaming capability to retrieve the xml and in dotnet the
ExecuteXmlreader command.
The result for ado com is :
<results><motor.cycle id="177496" ver="1" sum.insured="100000"
model="25089700" cover.type.id="0" make="546" capacity="1000" .....
The result for ado .net and in sql analyzer is :
<motor.cycle id="177496" ver="1" sum.insured="100000.0000" model="25089700"
cover.type.id="0" make="546" capacity="1.000000000000000e+003".....
It is clear that the money fields(sum..insured) and float fields(capacity)
gets converted(implicitly by SQL?) in different ways.
Does anyone know why it is not the same and how to get it the same?This is most likely an artefact of the XML serialization of the typed values
being done differently by the two providers (for some providers and FOR XML
queries, we are sending binary data over that then gets converted to strings
in the providers).
The ADO.Net serialization is consistent with the server-side serialization:
select cast(1000 as float) as x for XML raw, type
select Cast((select cast(1000 as float) as x for XML raw, type) as
nvarchar(max))
Note that management studio also uses ADO.Net.
If this is problematic, please let me know. Note that I am not sure however,
that we can change it now...
Best regards
Michael
"Eben" <eben@.fspsolutions.com> wrote in message
news:eGKV5vF5FHA.1956@.TK2MSFTNGP09.phx.gbl...
>I am running the same query through the traditional ado com interface and
>through dotnet ado. The query is a FOR XML EXPLICIT and in ado com I am
>using the streaming capability to retrieve the xml and in dotnet the
>ExecuteXmlreader command.
> The result for ado com is :
> <results><motor.cycle id="177496" ver="1" sum.insured="100000"
> model="25089700" cover.type.id="0" make="546" capacity="1000" .....
> The result for ado .net and in sql analyzer is :
> <motor.cycle id="177496" ver="1" sum.insured="100000.0000"
> model="25089700" cover.type.id="0" make="546"
> capacity="1.000000000000000e+003".....
> It is clear that the money fields(sum..insured) and float fields(capacity)
> gets converted(implicitly by SQL?) in different ways.
>
> Does anyone know why it is not the same and how to get it the same?
>

没有评论:

发表评论