我先从后台取数(xml格式),然后用:xmlStream: TStringStream;
...
dataset.LoadFromStream(xmlStream)
...将数据加载进dataset,其中有个字段rec_no,串里面是:fieldtype="f4",这个不是float型么??数据库里(oracle数据库,number字段)是存了小数的,读取出来却只有整数了!!!跟踪之后发现这个字段是ftBCD型,为什么不是ftFloat型呢?在取数前后都试了强制设置这个字段的数据类型为ftFloat,都不成我想存小数进去,如:ClientDataSet1.FindField('Rec_no').asFloat:=2.25;
ClientDataSet1.FindField('Rec_no').value:=2.25;都不成,只存了2,小数位丢失了!!!实在解决不了了,请教各位达人,谢谢!!解决了立马给分!!!

解决方案 »

  1.   

    xmlStream.datastring的值(最后面是数据,就不贴了):'<DATAPACKET Version="2.0">'#$D#$A#9'<METADATA>'#$D#$A#9#9'<FIELDS>'#$D#$A#9#9#9'<FIELD attrname="ACCOUNT_ID" fieldtype="string" WIDTH="30"/>'#$D#$A#9#9#9'<FIELD attrname="CODE" fieldtype="string" WIDTH="30"/>'#$D#$A#9#9#9'<FIELD attrname="COMMENTS" fieldtype="string" WIDTH="200"/>'#$D#$A#9#9#9'<FIELD attrname="CO_CODE" fieldtype="string" WIDTH="30"/>'#$D#$A#9#9#9'<FIELD attrname="DR_CR" fieldtype="i4" WIDTH="22"/>'#$D#$A#9#9#9'<FIELD attrname="FISCAL" fieldtype="i4" WIDTH="22"/>'#$D#$A#9#9#9'<FIELD attrname="IID" fieldtype="string" WIDTH="60"/>'#$D#$A#9#9#9'<FIELD attrname="IS_BK" fieldtype="string" WIDTH="1"/>'#$D#$A#9#9#9'<FIELD attrname="IS_FREEZED" fieldtype="string" WIDTH="1"/>'#$D#$A#9#9#9'<FIELD attrname="IS_LOWEST" fieldtype="string" WIDTH="1"/>'#$D#$A#9#9#9'<FIELD attrname="LB01" fieldtype="string" WIDTH="1"/>'#$D#$A#9#9#9'<FIELD attrname="LB02" fieldtype="string" WIDTH="1"/>'#$D#$A#9#9#9'<FIELD attrname="LB03" fieldtype="string" WIDTH="1"/>'#$D#$A#9#9#9'<FIELD attrname="LB04" fieldtype="string" WIDTH="1"/>'#$D#$A#9#9#9'<FIELD attrname="LB05" fieldtype="string" WIDTH="1"/>'#$D#$A#9#9#9'<FIELD attrname="LB06" fieldtype="string" WIDTH="1"/>'#$D#$A#9#9#9'<FIELD attrname="LB07" fieldtype="string" WIDTH="1"/>'#$D#$A#9#9#9'<FIELD attrname="LB08" fieldtype="string" WIDTH="1"/>'#$D#$A#9#9#9'<FIELD attrname="LB09" fieldtype="string" WIDTH="1"/>'#$D#$A#9#9#9'<FIELD attrname="LB10" fieldtype="string" WIDTH="1"/>'#$D#$A#9#9#9'<FIELD attrname="LB11" fieldtype="string" WIDTH="1"/>'#$D#$A#9#9#9'<FIELD attrname="LB12" fieldtype="string" WIDTH="1"/>'#$D#$A#9#9#9'<FIELD attrname="LB13" fieldtype="string" WIDTH="1"/>'#$D#$A#9#9#9'<FIELD attrname="LB14" fieldtype="string" WIDTH="1"/>'#$D#$A#9#9#9'<FIELD attrname="LB15" fieldtype="string" WIDTH="1"/>'#$D#$A#9#9#9'<FIELD attrname="LB16" fieldtype="string" WIDTH="1"/>'#$D#$A#9#9#9'<FIELD attrname="LB17" fieldtype="string" WIDTH="1"/>'#$D#$A#9#9#9'<FIELD attrname="LB18" fieldtype="string" WIDTH="1"/>'#$D#$A#9#9#9'<FIELD attrname="LB19" fieldtype="string" WIDTH="1"/>'#$D#$A#9#9#9'<FIELD attrname="LB20" fieldtype="string" WIDTH="1"/>'#$D#$A#9#9#9'<FIELD attrname="LEVEL_INDEX" fieldtype="i4" WIDTH="22"/>'#$D#$A#9#9#9'<FIELD attrname="NAME" fieldtype="string" WIDTH="200"/>'#$D#$A#9#9#9'<FIELD attrname="REC_NO" fieldtype="f4" WIDTH="22"/>'#$D#$A#9#9#9'<FIELD attrname="TYPE" fieldtype="string" WIDTH="30"/>'#$D#$A#9#9#9'<FIELD attrname="UP_CODE" fieldtype="string" WIDTH="60"/>'#$D#$A#9#9#9'<FIELD attrname="UP_CODE1" fieldtype="string" WIDTH="60"/>'#$D#$A#9#9#9'<FIELD attrname="UP_CODE10" fieldtype="string" WIDTH="60"/>'#$D#$A#9#9#9'<FIELD attrname="UP_CODE2" fieldtype="string" WIDTH="60"/>'#$D#$A#9#9#9'<FIELD attrname="UP_CODE3" fieldtype="string" WIDTH="60"/>'#$D#$A#9#9#9'<FIELD attrname="UP_CODE4" fieldtype="string" WIDTH="60"/>'#$D#$A#9#9#9'<FIELD attrname="UP_CODE5" fieldtype="string" WIDTH="60"/>'#$D#$A#9#9#9'<FIELD attrname="UP_CODE6" fieldtype="string" WIDTH="60"/>'#$D#$A#9#9#9'<FIELD attrname="UP_CODE7" fieldtype="string" WIDTH="60"/>'#$D#$A#9#9#9'<FIELD attrname="UP_CODE8" fieldtype="string" WIDTH="60"/>'#$D#$A#9#9#9'<FIELD attrname="UP_CODE9" fieldtype="string" WIDTH="60"/>'#$D#$A#9#9'</FIELDS>'#$D#$A#9'</METADATA>'#$D#$A#9'<ROWDATA>'#$D#$A#9#9'
      

  2.   

    将fieldtype="f4"换成
    FieldType = "float"
      

  3.   

    改成fieldtype="float"也不行,还是ftBCD型,怎么办啊
      

  4.   

    搞定,原来f8才是ftFloat型,谢谢前面这位了,分就给你吧
      

  5.   

    r8,我也遇到这个问题的。
    不过我现在遇到另外一个问题,不知哪位朋友有没有遇到过:
    用LoadFromStream,DateTime格式的数据,只有日期,没有时间了。
    Stream.Create的时候是对的,LoadFromStream之后再保存成xml就不对了。
    LoadFromFile就是可以的。