看看这段代码那里出错了!那位大侠帮帮我这个菜鸟啊!(40分)

  • 主题发起人 主题发起人 poim111
  • 开始时间 开始时间
P

poim111

Unregistered / Unconfirmed
GUEST, unregistred user!
COUNT_QUERY.Close; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br> &nbsp; &nbsp;COUNT_QUERY.SQL.Text:='SELECT TZNAME_TABLE.PROJECTNUMBER as 编码,TZNAME_TABLE.PROJECTFATHER AS 父编码, '<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+'TZdate_TABLE.WORKGS AS 概算工作量,TZdate_TABLE.WORKYS AS 预算工作量,TZdate_TABLE.TZWORKS AS 调整工作量,TZdate_TABLE.CWWORKS AS 财务决算工作量,'<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+'TZdate_TABLE.ADDCOUNT AS 累计工作量,TZdate_TABLE.OFYEAR AS 年份 FROM TZDATE_TABLE INNER JOIN TZNAME_TABLE '<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+'ON TZDATE_TABLE.PROJECTNUMBER = TZNAME_TABLE.PROJECTNUMBER order by TZNAME_TABLE.projectnumber DESC';<br> &nbsp; &nbsp;COUNT_QUERY.Open;<br> &nbsp; &nbsp;COUNT_QUERY.First;<br> &nbsp; &nbsp;while not COUNT_QUERY.Eof do<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp;COUNT_QUERY.Edit;<br> &nbsp; &nbsp; &nbsp; &nbsp;//概算工作量<br> &nbsp; &nbsp; &nbsp; &nbsp;ADOQuery1.Close;<br> &nbsp; &nbsp; &nbsp; &nbsp;ADOQuery1.SQL.Text:='select sum(WORKGS) as 概算工作量 from TZDATE_TABLE INNER JOIN TZNAME_TABLE '<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+'ON TZDATE_TABLE.PROJECTNUMBER = TZNAME_TABLE.PROJECTNUMBER where TZNAME_TABLE.projectfather='+#39+COUNT_QUERY.fieldbyname('编码').AsVariant+#39+' and ofyear='+COUNT_QUERY.fieldbyname('年份').AsString;<br> &nbsp; &nbsp; &nbsp; &nbsp;ADOQuery1.Open;<br> &nbsp; &nbsp; &nbsp; &nbsp;if ADOQuery1.FieldByName('概算工作量').AsInteger&lt;&gt;0 then<br> &nbsp; &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;COUNT_QUERY.FieldByName('概算工作量').AsVariant:=ADOQuery1.FieldByName('概算工作量').AsVariant;<br> &nbsp; &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//预算工作量<br> &nbsp; &nbsp; &nbsp; &nbsp;ADOQuery1.Close;<br> &nbsp; &nbsp; &nbsp; &nbsp;ADOQuery1.SQL.Text:='select sum(WORKYS) as 预算工作量 from TZDATE_TABLE INNER JOIN TZNAME_TABLE '<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+'ON TZDATE_TABLE.PROJECTNUMBER = TzNAME_TABLE.PROJECTNUMBER where projectfather='+#39+COUNT_QUERY.fieldbyname('编码').AsVariant+#39+' and ofyear='+COUNT_QUERY.fieldbyname('年份').AsString;<br> &nbsp; &nbsp; &nbsp; &nbsp;ADOQuery1.Open;<br> &nbsp; &nbsp; &nbsp; &nbsp;if ADOQuery1.FieldByName('预算工作量').AsInteger&lt;&gt;0 then<br> &nbsp; &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;COUNT_QUERY.FieldByName('预算工作量').AsVariant:=ADOQuery1.FieldByName('预算工作量').AsVariant;<br> &nbsp; &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp; &nbsp; &nbsp;//调整工作量<br> &nbsp; &nbsp; &nbsp; &nbsp;ADOQuery1.Close;<br> &nbsp; &nbsp; &nbsp; &nbsp;ADOQuery1.SQL.Text:='select sum(TZWORKS) as 调整工作量 from TZDATE_TABLE INNER JOIN TZName_TABLE '<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+'ON TZDATE_TABLE.PROJECTNUMBER = TZName_TABLE.PROJECTNUMBER where projectfather='+#39+COUNT_QUERY.fieldbyname('编码').AsVariant+#39+' and ofyear='+COUNT_QUERY.fieldbyname('年份').AsString;<br> &nbsp; &nbsp; &nbsp; &nbsp;ADOQuery1.Open;<br> &nbsp; &nbsp; &nbsp; &nbsp;if ADOQuery1.FieldByName('调整工作量').AsInteger&lt;&gt;0 then<br> &nbsp; &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;COUNT_QUERY.FieldByName('调整工作量').AsVariant:=ADOQuery1.FieldByName('调整工作量').AsVariant;<br> &nbsp; &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp; &nbsp; &nbsp;//财务工作量<br> &nbsp; &nbsp; &nbsp; &nbsp;ADOQuery1.Close;<br> &nbsp; &nbsp; &nbsp; &nbsp;ADOQuery1.SQL.Text:='select sum(CWWORKS) as 财务工作量 from TZDATE_TABLE INNER JOIN TZName_TABLE '<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+'ON TZDATE_TABLE.PROJECTNUMBER = TZName_TABLE.PROJECTNUMBER where projectfather='+#39+COUNT_QUERY.fieldbyname('编码').AsVariant+#39+' and ofyear='+COUNT_QUERY.fieldbyname('年份').AsString;<br> &nbsp; &nbsp; &nbsp; &nbsp;ADOQuery1.Open;<br> &nbsp; &nbsp; &nbsp; &nbsp;if ADOQuery1.FieldByName('财务工作量').AsInteger&lt;&gt;0 then<br> &nbsp; &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;COUNT_QUERY.FieldByName('财务决算工作量').AsVariant:=ADOQuery1.FieldByName('财务工作量').AsVariant;<br> &nbsp; &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp; &nbsp; &nbsp;//累计工作量<br> &nbsp; &nbsp; &nbsp; &nbsp;ADOQuery1.Close;<br> &nbsp; &nbsp; &nbsp; &nbsp;ADOQuery1.SQL.Text:='select sum(CWWORKS) as 累计工作量 from TZDATE_TABLE INNER JOIN TZName_TABLE '<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+'ON TZDATE_TABLE.PROJECTNUMBER = TZName_TABLE.PROJECTNUMBER where TZName_TABLE.projectnumber='+#39+COUNT_QUERY.fieldbyname('编码').AsVariant+#39+' and ofyear&lt;='+COUNT_QUERY.fieldbyname('年份').AsString;<br> &nbsp; &nbsp; &nbsp; &nbsp;ADOQuery1.Open;<br> &nbsp; &nbsp; &nbsp; &nbsp;if ADOQuery1.FieldByName('累计工作量').AsInteger&lt;&gt;0 then<br> &nbsp; &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;COUNT_QUERY.FieldByName('累计工作量').AsVariant:=ADOQuery1.FieldByName('累计工作量').AsVariant;<br> &nbsp; &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp; &nbsp; &nbsp;COUNT_QUERY.Post;<br> &nbsp; &nbsp; &nbsp; &nbsp;COUNT_QUERY.Next;<br> &nbsp; &nbsp;end;<br>错误提示:缺少更新或刷新的键列信息!<br>主键是有的,就算没有主键我这个得到的绝对也是唯一的数据结果集!<br>本人刚学检查了半天了找不到问题啊!还请大侠们指点一、二啊!
 
这是哪个人写的呀,新手吧。唉~~~~
 
表设计问题,查查数据库
 
同时更新相同行数据了,可能没有设置主键引起..要设置唯一主键..
 
晕,程序够戗啊,我看不到你表的设计,不好说.但是建议你先查找一下执行哪一句的时候报这个错,查找方法可以用showmessage来试试,程序太乱,书写也不太规范,只能给这个建议了.
 
能跟踪到是那条SQL语句?顺便把数据表也传上来参考一下呢
 
你不要在sql语句里面使用as关键字,也就是原来的列信息是什么就是什么,然后再看看能更新不,还有就是在你的另外一个帖子里面,我说的东西,自己看看!
 
我试过了,不用AS也不可以的,还有就是你所谓的那个CLEAR根本对我这段程序起不了什么作用,我那样做就剩了一步!直接给SQL内容更新不会再附加前面的内容的
 
后退
顶部