dbgrideh 进行数据统计 的问题。(100)

  • 主题发起人 主题发起人 京毛毛
  • 开始时间 开始时间

京毛毛

Unregistered / Unconfirmed
GUEST, unregistred user!
表结构 userid name address feiyong sfy 20090001 李四 地址 1500 张平 我需要统计的是查询结果第四个字段feiyong的和, dbgrideh1.footerrowcount:=1; dbgrideh1.sumlist.active:=true; dbgrideh1.column[3].footers[0].valuetype:=fvtsum; 可是执行时报错:adoquery1: field "feiyong" not found。 弄了很久也没有找出原因,请大家帮帮我。谢谢了
 
你的ADOUQUERY1的SQL语句是怎么写的,没有写FEIYONG这个字段吧
 
提示这个错,那就说明dbgrideh1在处理这个统计信息了。估计adoquery的sql有问题。也可以把 dbgrideh1.column[3].footers[0].valuetype:=fvtsum; 更改为dbgrideh1.column[3].footer.valuetype:=fvtsum; 因为你的footerrowcount=1.
 
我的查询语句是这样子的,不应该有问题呀 datasource1.DataSet :=adoquery1; dbgrideh1.DataSource :=datasource1; sqlstr:='select userid,name,address,feiyong,sfy from sfxx; with adoquery1 do begin close; sql.Clear; sql.Add(sqlstr); open; end;
 
feiyong 字段的类型有要求吗,我这个是float型的,有没有问题。着急,在线等.....
 
你feiyong下的统计字段设定好字段了吗?float肯定成的
 
先不设置dbgrideh1.sumlist.active:=true;,看看有没有错误提示,如果有,那就说明错误不在这里了。另外检查dbgrideh的columneh,在设置fieldname的时候,有没有多输入空格导致异常。
 
to zkktom,你是说dbgrideh1.column[3].footer[0].fieldname:=feiyong;是吗,也不行,一样的错误提示
 
to znxia:dbgrideh1.sumlist.active:=false;//可以查询出结果fieldname设置没有问题。一加上统计功能,就报错。还会是哪里有问题呢?[:(]
 
算了,你在delphi编辑器中,选择现在dbgrideh,然后拷贝,粘贴到这里面来,让大家看一下属性设置情况吧。
 
object DBGridEh1: TDBGridEh Left = 48 Top = 136 Width = 353 Height = 120 AutoFitColWidths = True FooterColor = clWindow FooterFont.Charset = DEFAULT_CHARSET FooterFont.Color = clWindowText FooterFont.Height = -11 FooterFont.Name = 'MS Sans Serif' FooterFont.Style = [] FooterRowCount = 1 ImeName = #20013#25991' ('#31616#20307') - '#25628#29399#25340#38899#36755#20837#27861 SumList.Active = True TabOrder = 0 TitleFont.Charset = DEFAULT_CHARSET TitleFont.Color = clWindowText TitleFont.Height = -11 TitleFont.Name = 'MS Sans Serif' TitleFont.Style = [] Columns = < item EditButtons = <> FieldName = 'userid' Footers = <> end item EditButtons = <> FieldName = 'name' Footers = <> end item EditButtons = <> FieldName = 'address' Footers = <> end item EditButtons = <> FieldName = 'feiyong' Footers = < item Color = clYellow ValueType = fvtSum end> end item EditButtons = <> FieldName = 'sfy' Footers = <> end>end
 
上一个没设置fieldname,看这个吧,大家费心了object DBGridEh1: TDBGridEh Left = 48 Top = 136 Width = 353 Height = 120 AutoFitColWidths = True FooterColor = clWindow FooterFont.Charset = DEFAULT_CHARSET FooterFont.Color = clWindowText FooterFont.Height = -11 FooterFont.Name = 'MS Sans Serif' FooterFont.Style = [] FooterRowCount = 1 ImeName = #20013#25991' ('#31616#20307') - '#25628#29399#25340#38899#36755#20837#27861 SumList.Active = True TabOrder = 0 TitleFont.Charset = DEFAULT_CHARSET TitleFont.Color = clWindowText TitleFont.Height = -11 TitleFont.Name = 'MS Sans Serif' TitleFont.Style = [] Columns = < item EditButtons = <> FieldName = 'userid' Footers = <> end item EditButtons = <> FieldName = 'name' Footers = <> end item EditButtons = <> FieldName = 'address' Footers = <> end item EditButtons = <> FieldName = 'feiyong' Footers = < item Color = clYellow FieldName = 'feiyong' ValueType = fvtSum end> end item EditButtons = <> FieldName = 'sfy' Footers = <> end>end
 
晕啊!测试了,没有异常。
 
可是我的就是不行啊,我晕倒了
 
重新做一个测试程序来试试吧。
 
找到问题了,我在formcreate里用adoquery1 查询数据添加到combobox里,用adoquery2就可以了,害的大家费神尤其是znxia。散分了
 
多人接受答案了。
 
后退
顶部