大狭们看看这段代码为什么出错,delphi5.0+paradox数据库(100分)

  • 主题发起人 主题发起人 libaoliang
  • 开始时间 开始时间
L

libaoliang

Unregistered / Unconfirmed
GUEST, unregistred user!
大狭们看看这段代码为什么出错,delphi5.0+paradox数据库
其中table1-table9 分别代表 cktjbb1-cktjbb9 数据库
以前是可以执行的,当cktjbb1-cktjbb9 这9个数据库各在其最后增加了两个字段a8,l9后
就不行了,另外这种query组件的多次使用方式是否合理,
设计风格是否有问题?欢迎指教!

出问题的是被//的代码部分,其它可以
procedure TForm1.BitBtn1Click(Sender: TObject);
var s,s1,s2,s3,s4,s5,s6,s7,s8:string;
begin
with table1 do
begin
close;
emptytable;
end;
with table2 do
begin
close;
emptytable;
end;
with table3 do
begin
close;
emptytable;
end;
with table4 do
begin
close;
emptytable;
end;
with table5 do
begin
close;
emptytable;
end;
with table6 do
begin
close;
emptytable;
end;
with table7 do
begin
close;
emptytable;
end;
with table8 do
begin
close;
emptytable;
end;
with table9 do
begin
close;
emptytable;
end;
// s:='insert into cktjbb1(bz,cpmc,rys,yjp,yjl,hgs,hgl,dwp,fp,a1,l1,a2,l2,a3,l3,a4,l4,a5,l5,a6,l6,a7,l7,hj,l8,a8,l9) select bz,';
// s:=s+'cpmc,sum(rys),sum(yjp),sum(yjp)*100/sum(rys),sum(hgs),sum(hgs)*100/sum(rys),sum(dwp),sum(fp),';
// s:=s+'sum(a1),sum(a1)*100/sum(rys),sum(a2),sum(a2)*100/sum(rys),sum(a3),sum(a3)*100/sum(rys),';
// s:=s+'sum(a4),sum(a4)*100/sum(rys),sum(a5),sum(a5)*100/sum(rys),asum(a6),sum(a6)*100/sum(rys),';
// s:=s+'sum(a7),sum(a7)*100/sum(rys),sum(a1+a2+a3+a4+a5+a6+a7),sum(a1+a2+a3+a4+a5+a6+a7)*100/sum(rys),sum(a8),sum(a8)*100/sum(rys) ';
// s:=s+'from cpkck where (rq between :rq1 and :rq2) group by bz,cpmc';
// query1.close;
// query1.sql.Clear;
// query1.sql.add(s);
// query1.parambyname('rq1').asdate:=datetimepicker1.date;
// query1.parambyname('rq2').asdate:=datetimepicker2.date;
// query1.execsql;
s:='select bz as 班组,cpmc as 产品名称,sum(rys) as 入窑数,sum(yjp) as 一级品,sum(yjp)*100/sum(rys) as 一级率,';
s:=s+'sum(hgs) as 合格数,sum(hgs)*100/sum(rys) as 合格率,';
s:=s+'sum(dwp) as 等外品,sum(fp) as 废品,';
s:=s+'sum(a1) as 炸瓷,sum(a1)*100/sum(rys) as 比率,';
s:=s+'sum(a2) as 爆花,sum(a2)*100/sum(rys) as 比率,';
s:=s+'sum(a3) as 断线,sum(a3)*100/sum(rys) as 比率,';
s:=s+'sum(a4) as 脏金,sum(a4)*100/sum(rys) as 比率,';
s:=s+'sum(a5) as 色脏,sum(a5)*100/sum(rys) as 比率,';
s:=s+'sum(a6) as 磕碰,sum(a6)*100/sum(rys) as 比率,';
s:=s+'sum(a8) as 白瓷过序,sum(a8)*100/sum(rys) as 比率,';
s:=s+'sum(a7) as 其它,sum(a7)*100/sum(rys) as 比率,';
s:=s+'sum(a1+a2+a3+a4+a5+a6+a7+a8) as 缺陷合计,sum(a1+a2+a3+a4+a5+a6+a7+a8)*100/sum(rys) as 比率';
s:=s+' from cpkck where (rq between :rq1 and :rq2) group by bz,cpmc';
query1.close;
query1.sql.Clear;
query1.sql.add(s);
query1.parambyname('rq1').asdate:=datetimepicker1.date;
query1.parambyname('rq2').asdate:=datetimepicker2.date;
query1.Open;
// s1:='insert into cktjbb2(cpmc,rys,yjp,yjl,hgs,hgl,dwp,fp,a1,l1,a2,l2,a3,l3,a4,l4,a5,l5,a6,l6,a7,l7,hj,l8,a8,l9) select cpmc,';
// s1:='insert into cktjbb2(cpmc,rys,yjp,yjl,hgs,hgl,dwp,fp,a1,l1,a2,l2,a3,l3,a4,l4,a5,l5,a6,l6,a7,l7,hj,l8) select cpmc,';
// s1:=s1+'sum(rys),sum(yjp),sum(yjp)*100/sum(rys),sum(hgs),sum(hgs)*100/sum(rys),sum(dwp),sum(fp),';
// s1:=s1+'sum(a1),sum(a1)*100/sum(rys),sum(a2),sum(a2)*100/sum(rys),sum(a3),sum(a3)*100/sum(rys),';
// s1:=s1+'sum(a4),sum(a4)*100/sum(rys),sum(a5),sum(a5)*100/sum(rys),sum(a6),sum(a6)*100/sum(rys),';
// s1:=s1+'sum(a7),sum(a7)*100/sum(rys),sum(a1+a2+a3+a4+a5+a6+a7+a8),sum(a1+a2+a3+a4+a5+a6+a7+a8)*100/sum(rys)';
// s1:=s1+' from cpkck where (rq between :rq1 and :rq2) group by cpmc';
// query2.close;
// query2.sql.Clear;
// query2.sql.add(s1);
// query2.parambyname('rq1').asdate:=datetimepicker1.date;
// query2.parambyname('rq2').asdate:=datetimepicker2.date;
// query2.execsql;
s1:='select cpmc as 产品名称,sum(rys) as 入窑数,sum(yjp) as 一级品,sum(yjp)*100/sum(rys) as 一级率,';
s1:=s1+'sum(hgs) as 合格数,sum(hgs)*100/sum(rys) as 合格率,';
s1:=s1+'sum(dwp) as 等外品,sum(fp) as 废品,';
s1:=s1+'sum(a1) as 炸瓷,sum(a1)*100/sum(rys) as 比率,';
s1:=s1+'sum(a2) as 爆花,sum(a2)*100/sum(rys) as 比率,';
s1:=s1+'sum(a3) as 断线,sum(a3)*100/sum(rys) as 比率,';
s1:=s1+'sum(a4) as 脏金,sum(a4)*100/sum(rys) as 比率,';
s1:=s1+'sum(a5) as 色脏,sum(a5)*100/sum(rys) as 比率,';
s1:=s1+'sum(a6) as 磕碰,sum(a6)*100/sum(rys) as 比率,';
s1:=s1+'sum(a8) as 白瓷过序,sum(a8)*100/sum(rys) as 比率,';
s1:=s1+'sum(a7) as 其它,sum(a7)*100/sum(rys) as 比率,';
s1:=s1+'sum(a1+a2+a3+a4+a5+a6+a7+a8) as 缺陷合计,sum(a1+a2+a3+a4+a5+a6+a7+a8)*100/sum(rys) as 比率';
s1:=s1+' from cpkck where (rq between :rq1 and :rq2) group by cpmc';
query2.close;
query2.sql.Clear;
query2.sql.add(s1);
query2.parambyname('rq1').asdate:=datetimepicker1.date;
query2.parambyname('rq2').asdate:=datetimepicker2.date;
query2.Open;
// s2:='insert into cktjbb3(thxm,cpmc,rys,yjp,yjl,hgs,hgl,dwp,fp,a1,l1,a2,l2,a3,l3,a4,l4,a5,l5,a6,l6,a7,l7,hj,l8,a8,l9) select thxm,';
// s2:='insert into cktjbb3(thxm,cpmc,rys,yjp,yjl,hgs,hgl,dwp,fp,a1,l1,a2,l2,a3,l3,a4,l4,a5,l5,a6,l6,a7,l7,hj,l8) select thxm,';
// s2:=s2+'cpmc,sum(rys),sum(yjp),sum(yjp)*100/sum(rys),sum(hgs),sum(hgs)*100/sum(rys),sum(dwp),sum(fp),';
// s2:=s2+'sum(a1),sum(a1)*100/sum(rys),sum(a2),sum(a2)*100/sum(rys),sum(a3),sum(a3)*100/sum(rys),';
// s2:=s2+'sum(a4),sum(a4)*100/sum(rys),sum(a5),sum(a5)*100/sum(rys),sum(a6),sum(a6)*100/sum(rys),';
// s2:=s2+'sum(a7),sum(a7)*100/sum(rys),sum(a1+a2+a3+a4+a5+a6+a7+a8),sum(a1+a2+a3+a4+a5+a6+a7+a8)*100/sum(rys)';
// s2:=s2+' from cpkck where (rq between :rq1 and :rq2) group by thxm,cpmc';
// query3.close;
// query3.sql.Clear;
// query3.sql.add(s2);
// query3.parambyname('rq1').asdate:=datetimepicker1.date;
// query3.parambyname('rq2').asdate:=datetimepicker2.date;
// query3.execsql;
s2:='select thxm as 贴花人,cpmc as 产品名称,sum(rys) as 入窑数,sum(yjp) as 一级品,sum(yjp)*100/sum(rys) as 一级率,';
s2:=s2+'sum(hgs) as 合格数,sum(hgs)*100/sum(rys) as 合格率,';
s2:=s2+'sum(dwp) as 等外品,sum(fp) as 废品,';
s2:=s2+'sum(a1) as 炸瓷,sum(a1)*100/sum(rys) as 比率,';
s2:=s2+'sum(a2) as 爆花,sum(a2)*100/sum(rys) as 比率,';
s2:=s2+'sum(a3) as 断线,sum(a3)*100/sum(rys) as 比率,';
s2:=s2+'sum(a4) as 脏金,sum(a4)*100/sum(rys) as 比率,';
s2:=s2+'sum(a5) as 色脏,sum(a5)*100/sum(rys) as 比率,';
s2:=s2+'sum(a6) as 磕碰,sum(a6)*100/sum(rys) as 比率,';
s2:=s2+'sum(a8) as 白瓷过序,sum(a8)*100/sum(rys) as 比率,';
s2:=s2+'sum(a7) as 其它,sum(a7)*100/sum(rys) as 比率,';
s2:=s2+'sum(a1+a2+a3+a4+a5+a6+a7+a8) as 缺陷合计,sum(a1+a2+a3+a4+a5+a6+a7+a8)*100/sum(rys) as 比率';
s2:=s2+' from cpkck where (rq between :rq1 and :rq2) group by thxm,cpmc';
query3.close;
query3.sql.Clear;
query3.sql.add(s2);
query3.parambyname('rq1').asdate:=datetimepicker1.date;
query3.parambyname('rq2').asdate:=datetimepicker2.date;
query3.Open;
// s3:='insert into cktjbb4(mkxm,cpmc,rys,yjp,yjl,hgs,hgl,dwp,fp,a1,l1,a2,l2,a3,l3,a4,l4,a5,l5,a6,l6,a7,l7,hj,l8,a8,l9) select mkxm,';
// s3:='insert into cktjbb4(mkxm,cpmc,rys,yjp,yjl,hgs,hgl,dwp,fp,a1,l1,a2,l2,a3,l3,a4,l4,a5,l5,a6,l6,a7,l7,hj,l8) select mkxm,';
// s3:=s3+'cpmc,sum(rys),sum(yjp),sum(yjp)*100/sum(rys),sum(hgs),sum(hgs)*100/sum(rys),sum(dwp),sum(fp),';
// s3:=s3+'sum(a1),sum(a1)*100/sum(rys),sum(a2),sum(a2)*100/sum(rys),sum(a3),sum(a3)*100/sum(rys),';
// s3:=s3+'sum(a4),sum(a4)*100/sum(rys),sum(a5),sum(a5)*100/sum(rys),sum(a6),sum(a6)*100/sum(rys),';
// s3:=s3+'sum(a7),sum(a7)*100/sum(rys),sum(a1+a2+a3+a4+a5+a6+a7+a8),sum(a1+a2+a3+a4+a5+a6+a7+a8)*100/sum(rys)';
// s3:=s3+' from cpkck where (rq between :rq1 and :rq2) group by mkxm,cpmc';
// query4.close;
// query4.sql.Clear;
// query4.sql.add(s3);
// query4.parambyname('rq1').asdate:=datetimepicker1.date;
// query4.parambyname('rq2').asdate:=datetimepicker2.date;
// query4.execsql;
s3:='select mkxm as 抹口人,cpmc as 产品名称,sum(rys) as 入窑数,sum(yjp) as 一级品,sum(yjp)*100/sum(rys) as 一级率,';
s3:=s3+'sum(hgs) as 合格数,sum(hgs)*100/sum(rys) as 合格率,';
s3:=s3+'sum(dwp) as 等外品,sum(fp) as 废品,';
s3:=s3+'sum(a1) as 炸瓷,sum(a1)*100/sum(rys) as 比率,';
s3:=s3+'sum(a2) as 爆花,sum(a2)*100/sum(rys) as 比率,';
s3:=s3+'sum(a3) as 断线,sum(a3)*100/sum(rys) as 比率,';
s3:=s3+'sum(a4) as 脏金,sum(a4)*100/sum(rys) as 比率,';
s3:=s3+'sum(a5) as 色脏,sum(a5)*100/sum(rys) as 比率,';
s3:=s3+'sum(a6) as 磕碰,sum(a6)*100/sum(rys) as 比率,';
s3:=s3+'sum(a8) as 白瓷过序,sum(a8)*100/sum(rys) as 比率,';
s3:=s3+'sum(a7) as 其它,sum(a7)*100/sum(rys) as 比率,';
s3:=s3+'sum(a1+a2+a3+a4+a5+a6+a7+a8) as 缺陷合计,sum(a1+a2+a3+a4+a5+a6+a7+a8)*100/sum(rys) as 比率';
s3:=s3+' from cpkck where (rq between :rq1 and :rq2) group by mkxm,cpmc';
query4.close;
query4.sql.Clear;
query4.sql.add(s3);
query4.parambyname('rq1').asdate:=datetimepicker1.date;
query4.parambyname('rq2').asdate:=datetimepicker2.date;
query4.Open;
// s4:='insert into cktjbb5(jxxm,cpmc,rys,yjp,yjl,hgs,hgl,dwp,fp,a1,l1,a2,l2,a3,l3,a4,l4,a5,l5,a6,l6,a7,l7,hj,l8,a8,l9) select jxxm,';
// s4:='insert into cktjbb5(jxxm,cpmc,rys,yjp,yjl,hgs,hgl,dwp,fp,a1,l1,a2,l2,a3,l3,a4,l4,a5,l5,a6,l6,a7,l7,hj,l8) select jxxm,';
// s4:=s4+'cpmc,sum(rys),sum(yjp),sum(yjp)*100/sum(rys),sum(hgs),sum(hgs)*100/sum(rys),sum(dwp),sum(fp),';
// s4:=s4+'sum(a1),sum(a1)*100/sum(rys),sum(a2),sum(a2)*100/sum(rys),sum(a3),sum(a3)*100/sum(rys),';
// s4:=s4+'sum(a4),sum(a4)*100/sum(rys),sum(a5),sum(a5)*100/sum(rys),sum(a6),sum(a6)*100/sum(rys),';
// s4:=s4+'sum(a7),sum(a7)*100/sum(rys),sum(a1+a2+a3+a4+a5+a6+a7+a8),sum(a1+a2+a3+a4+a5+a6+a7+a8)*100/sum(rys)';
// s4:=s4+' from cpkck where (rq between :rq1 and :rq2) group by jxxm,cpmc';
// query5.close;
// query5.sql.Clear;
// query5.sql.add(s4);
// query5.parambyname('rq1').asdate:=datetimepicker1.date;
// query5.parambyname('rq2').asdate:=datetimepicker2.date;
// query5.execsql;
s4:='select jxxm as 介线人,cpmc as 产品名称,sum(rys) as 入窑数,sum(yjp) as 一级品,sum(yjp)*100/sum(rys) as 一级率,';
s4:=s4+'sum(hgs) as 合格数,sum(hgs)*100/sum(rys) as 合格率,';
s4:=s4+'sum(dwp) as 等外品,sum(fp) as 废品,';
s4:=s4+'sum(a1) as 炸瓷,sum(a1)*100/sum(rys) as 比率,';
s4:=s4+'sum(a2) as 爆花,sum(a2)*100/sum(rys) as 比率,';
s4:=s4+'sum(a3) as 断线,sum(a3)*100/sum(rys) as 比率,';
s4:=s4+'sum(a4) as 脏金,sum(a4)*100/sum(rys) as 比率,';
s4:=s4+'sum(a5) as 色脏,sum(a5)*100/sum(rys) as 比率,';
s4:=s4+'sum(a6) as 磕碰,sum(a6)*100/sum(rys) as 比率,';
s4:=s4+'sum(a8) as 白瓷过序,sum(a8)*100/sum(rys) as 比率,';
s4:=s4+'sum(a7) as 其它,sum(a7)*100/sum(rys) as 比率,';
s4:=s4+'sum(a1+a2+a3+a4+a5+a6+a7+a8) as 缺陷合计,sum(a1+a2+a3+a4+a5+a6+a7+a8)*100/sum(rys) as 比率';
s4:=s4+' from cpkck where (rq between :rq1 and :rq2) group by jxxm,cpmc';
query5.close;
query5.sql.Clear;
query5.sql.add(s4);
query5.parambyname('rq1').asdate:=datetimepicker1.date;
query5.parambyname('rq2').asdate:=datetimepicker2.date;
query5.Open;
// s5:='insert into cktjbb6(khxm,cpmc,rys,yjp,yjl,hgs,hgl,dwp,fp,a1,l1,a2,l2,a3,l3,a4,l4,a5,l5,a6,l6,a7,l7,hj,l8,a8,l9) select khxm,';
// s5:='insert into cktjbb6(khxm,cpmc,rys,yjp,yjl,hgs,hgl,dwp,fp,a1,l1,a2,l2,a3,l3,a4,l4,a5,l5,a6,l6,a7,l7,hj,l8) select khxm,';
// s5:=s5+'cpmc,sum(rys),sum(yjp),sum(yjp)*100/sum(rys),sum(hgs),sum(hgs)*100/sum(rys),sum(dwp),sum(fp),';
// s5:=s5+'sum(a1),sum(a1)*100/sum(rys),sum(a2),sum(a2)*100/sum(rys),sum(a3),sum(a3)*100/sum(rys),';
// s5:=s5+'sum(a4),sum(a4)*100/sum(rys),sum(a5),sum(a5)*100/sum(rys),sum(a6),sum(a6)*100/sum(rys),';
// s5:=s5+'sum(a7),sum(a7)*100/sum(rys),sum(a1+a2+a3+a4+a5+a6+a7+a8),sum(a1+a2+a3+a4+a5+a6+a7+a8)*100/sum(rys)';
// s5:=s5+' from cpkck where (rq between :rq1 and :rq2) group by khxm,cpmc';
// query6.close;
// query6.sql.Clear;
// query6.sql.add(s5);
// query6.parambyname('rq1').asdate:=datetimepicker1.date;
// query6.parambyname('rq2').asdate:=datetimepicker2.date;
// query6.execsql;
s5:='select khxm as 烤花人,cpmc as 产品名称,sum(rys) as 入窑数,sum(yjp) as 一级品,sum(yjp)*100/sum(rys) as 一级率,';
s5:=s5+'sum(hgs) as 合格数,sum(hgs)*100/sum(rys) as 合格率,';
s5:=s5+'sum(dwp) as 等外品,sum(fp) as 废品,';
s5:=s5+'sum(a1) as 炸瓷,sum(a1)*100/sum(rys) as 比率,';
s5:=s5+'sum(a2) as 爆花,sum(a2)*100/sum(rys) as 比率,';
s5:=s5+'sum(a3) as 断线,sum(a3)*100/sum(rys) as 比率,';
s5:=s5+'sum(a4) as 脏金,sum(a4)*100/sum(rys) as 比率,';
s5:=s5+'sum(a5) as 色脏,sum(a5)*100/sum(rys) as 比率,';
s5:=s5+'sum(a6) as 磕碰,sum(a6)*100/sum(rys) as 比率,';
s5:=s5+'sum(a8) as 白瓷过序,sum(a8)*100/sum(rys) as 比率,';
s5:=s5+'sum(a7) as 其它,sum(a7)*100/sum(rys) as 比率,';
s5:=s5+'sum(a1+a2+a3+a4+a5+a6+a7+a8) as 缺陷合计,sum(a1+a2+a3+a4+a5+a6+a7+a8)*100/sum(rys) as 比率';
s5:=s5+' from cpkck where (rq between :rq1 and :rq2) group by khxm,cpmc';
query6.close;
query6.sql.Clear;
query6.sql.add(s5);
query6.parambyname('rq1').asdate:=datetimepicker1.date;
query6.parambyname('rq2').asdate:=datetimepicker2.date;
query6.Open;
// s6:='insert into cktjbb7(jsxm,cpmc,rys,yjp,yjl,hgs,hgl,dwp,fp,a1,l1,a2,l2,a3,l3,a4,l4,a5,l5,a6,l6,a7,l7,hj,l8,a8,l9) select jsxm,';
// s6:='insert into cktjbb7(jsxm,cpmc,rys,yjp,yjl,hgs,hgl,dwp,fp,a1,l1,a2,l2,a3,l3,a4,l4,a5,l5,a6,l6,a7,l7,hj,l8) select jsxm,';
// s6:=s6+'cpmc,sum(rys),sum(yjp),sum(yjp)*100/sum(rys),sum(hgs),sum(hgs)*100/sum(rys),sum(dwp),sum(fp),';
// s6:=s6+'sum(a1),sum(a1)*100/sum(rys),sum(a2),sum(a2)*100/sum(rys),sum(a3),sum(a3)*100/sum(rys),';
// s6:=s6+'sum(a4),sum(a4)*100/sum(rys),sum(a5),sum(a5)*100/sum(rys),sum(a6),sum(a6)*100/sum(rys),';
// s6:=s6+'sum(a7),sum(a7)*100/sum(rys),sum(a1+a2+a3+a4+a5+a6+a7+a8),sum(a1+a2+a3+a4+a5+a6+a7+a8)*100/sum(rys)';
// s6:=s6+' from cpkck where (rq between :rq1 and :rq2) group by jsxm,cpmc';
// query7.close;
// query7.sql.Clear;
// query7.sql.add(s6);
// query7.parambyname('rq1').asdate:=datetimepicker1.date;
// query7.parambyname('rq2').asdate:=datetimepicker2.date;
// query7.execsql;
s6:='select jsxm as 检选人,cpmc as 产品名称,sum(rys) as 入窑数,sum(yjp) as 一级品,sum(yjp)*100/sum(rys) as 一级率,';
s6:=s6+'sum(hgs) as 合格数,sum(hgs)*100/sum(rys) as 合格率,';
s6:=s6+'sum(dwp) as 等外品,sum(fp) as 废品,';
s6:=s6+'sum(a1) as 炸瓷,sum(a1)*100/sum(rys) as 比率,';
s6:=s6+'sum(a2) as 爆花,sum(a2)*100/sum(rys) as 比率,';
s6:=s6+'sum(a3) as 断线,sum(a3)*100/sum(rys) as 比率,';
s6:=s6+'sum(a4) as 脏金,sum(a4)*100/sum(rys) as 比率,';
s6:=s6+'sum(a5) as 色脏,sum(a5)*100/sum(rys) as 比率,';
s6:=s6+'sum(a6) as 磕碰,sum(a6)*100/sum(rys) as 比率,';
s6:=s6+'sum(a8) as 白瓷过序,sum(a8)*100/sum(rys) as 比率,';
s6:=s6+'sum(a7) as 其它,sum(a7)*100/sum(rys) as 比率,';
s6:=s6+'sum(a1+a2+a3+a4+a5+a6+a7+a8) as 缺陷合计,sum(a1+a2+a3+a4+a5+a6+a7+a8)*100/sum(rys) as 比率';
s6:=s6+' from cpkck where (rq between :rq1 and :rq2) group by jsxm,cpmc';
query7.close;
query7.sql.Clear;
query7.sql.add(s6);
query7.parambyname('rq1').asdate:=datetimepicker1.date;
query7.parambyname('rq2').asdate:=datetimepicker2.date;
query7.Open;
// s7:='insert into cktjbb8(cpmc,hh,rys,yjp,yjl,hgs,hgl,dwp,fp,a1,l1,a2,l2,a3,l3,a4,l4,a5,l5,a6,l6,a7,l7,hj,l8,a8,l9) select cpmc,hh,';
// s7:='insert into cktjbb8(cpmc,hh,rys,yjp,yjl,hgs,hgl,dwp,fp,a1,l1,a2,l2,a3,l3,a4,l4,a5,l5,a6,l6,a7,l7,hj,l8) select cpmc,hh,';
// s7:=s7+'sum(rys),sum(yjp),sum(yjp)*100/sum(rys),sum(hgs),sum(hgs)*100/sum(rys),sum(dwp),sum(fp),';
// s7:=s7+'sum(a1),sum(a1)*100/sum(rys),sum(a2),sum(a2)*100/sum(rys),sum(a3),sum(a3)*100/sum(rys),';
// s7:=s7+'sum(a4),sum(a4)*100/sum(rys),sum(a5),sum(a5)*100/sum(rys),sum(a6),sum(a6)*100/sum(rys),';
// s7:=s7+'sum(a7),sum(a7)*100/sum(rys),sum(a1+a2+a3+a4+a5+a6+a7+a8),sum(a1+a2+a3+a4+a5+a6+a7+a8)*100/sum(rys)';
// s7:=s7+' from cpkck where (rq between :rq1 and :rq2) group by cpmc,hh';
// query8.close;
// query8.sql.Clear;
// query8.sql.add(s7);
// query8.parambyname('rq1').asdate:=datetimepicker1.date;
// query8.parambyname('rq2').asdate:=datetimepicker2.date;
// query8.execsql;
s7:='select cpmc as 产品名称,hh as 花号,sum(rys) as 入窑数,sum(yjp) as 一级品,sum(yjp)*100/sum(rys) as 一级率,';
s7:=s7+'sum(hgs) as 合格数,sum(hgs)*100/sum(rys) as 合格率,';
s7:=s7+'sum(dwp) as 等外品,sum(fp) as 废品,';
s7:=s7+'sum(a1) as 炸瓷,sum(a1)*100/sum(rys) as 比率,';
s7:=s7+'sum(a2) as 爆花,sum(a2)*100/sum(rys) as 比率,';
s7:=s7+'sum(a3) as 断线,sum(a3)*100/sum(rys) as 比率,';
s7:=s7+'sum(a4) as 脏金,sum(a4)*100/sum(rys) as 比率,';
s7:=s7+'sum(a5) as 色脏,sum(a5)*100/sum(rys) as 比率,';
s7:=s7+'sum(a6) as 磕碰,sum(a6)*100/sum(rys) as 比率,';
s7:=s7+'sum(a8) as 白瓷过序,sum(a8)*100/sum(rys) as 比率,';
s7:=s7+'sum(a7) as 其它,sum(a7)*100/sum(rys) as 比率,';
s7:=s7+'sum(a1+a2+a3+a4+a5+a6+a7+a8) as 缺陷合计,sum(a1+a2+a3+a4+a5+a6+a7+a8)*100/sum(rys) as 比率';
s7:=s7+' from cpkck where (rq between :rq1 and :rq2) group by cpmc,hh';
query8.close;
query8.sql.Clear;
query8.sql.add(s7);
query8.parambyname('rq1').asdate:=datetimepicker1.date;
query8.parambyname('rq2').asdate:=datetimepicker2.date;
query8.Open;
// s8:='insert into cktjbb9(thxm,cpmc,hh,rys,yjp,yjl,hgs,hgl,dwp,fp,a1,l1,a2,l2,a3,l3,a4,l4,a5,l5,a6,l6,a7,l7,hj,l8,a8,l9) select thxm,cpmc,hh,';
// s8:='insert into cktjbb9(thxm,cpmc,hh,rys,yjp,yjl,hgs,hgl,dwp,fp,a1,l1,a2,l2,a3,l3,a4,l4,a5,l5,a6,l6,a7,l7,hj,l8) select thxm,cpmc,hh,';
// s8:=s8+'sum(rys),sum(yjp),sum(yjp)*100/sum(rys),sum(hgs),sum(hgs)*100/sum(rys),sum(dwp),sum(fp),';
// s8:=s8+'sum(a1),sum(a1)*100/sum(rys),sum(a2),sum(a2)*100/sum(rys),sum(a3),sum(a3)*100/sum(rys),';
// s8:=s8+'sum(a4),sum(a4)*100/sum(rys),sum(a5),sum(a5)*100/sum(rys),sum(a6),sum(a6)*100/sum(rys),';
// s8:=s8+'sum(a7),sum(a7)*100/sum(rys),sum(a1+a2+a3+a4+a5+a6+a7+a8),sum(a1+a2+a3+a4+a5+a6+a7+a8)*100/sum(rys)';
// s8:=s8+' from cpkck where (rq between :rq1 and :rq2) group by thxm,cpmc,hh';
// query9.close;
// query9.sql.Clear;
// query9.sql.add(s8);
// query9.parambyname('rq1').asdate:=datetimepicker1.date;
// query9.parambyname('rq2').asdate:=datetimepicker2.date;
// query9.execsql;
s8:='select thxm as 贴花人,cpmc as 产品名称,hh as 花号,sum(rys) as 入窑数,sum(yjp) as 一级品,sum(yjp)*100/sum(rys) as 一级率,';
s8:=s8+'sum(hgs) as 合格数,sum(hgs)*100/sum(rys) as 合格率,';
s8:=s8+'sum(dwp) as 等外品,sum(fp) as 废品,';
s8:=s8+'sum(a1) as 炸瓷,sum(a1)*100/sum(rys) as 比率,';
s8:=s8+'sum(a2) as 爆花,sum(a2)*100/sum(rys) as 比率,';
s8:=s8+'sum(a3) as 断线,sum(a3)*100/sum(rys) as 比率,';
s8:=s8+'sum(a4) as 脏金,sum(a4)*100/sum(rys) as 比率,';
s8:=s8+'sum(a5) as 色脏,sum(a5)*100/sum(rys) as 比率,';
s8:=s8+'sum(a6) as 磕碰,sum(a6)*100/sum(rys) as 比率,';
s8:=s8+'sum(a8) as 白瓷过序,sum(a8)*100/sum(rys) as 比率,';
s8:=s8+'sum(a7) as 其它,sum(a7)*100/sum(rys) as 比率,';
s8:=s8+'sum(a1+a2+a3+a4+a5+a6+a7+a8) as 缺陷合计,sum(a1+a2+a3+a4+a5+a6+a7+a8)*100/sum(rys) as 比率';
s8:=s8+' from cpkck where (rq between :rq1 and :rq2) group by thxm,cpmc,hh';
query9.close;
query9.sql.Clear;
query9.sql.add(s8);
query9.parambyname('rq1').asdate:=datetimepicker1.date;
query9.parambyname('rq2').asdate:=datetimepicker2.date;
query9.Open;
end;
 
s7:=s7+'sum(hgs) as 合格数,sum(hgs)*100/sum(rys) as 合格率,';
s7:=s7+'sum(dwp) as 等外品,sum(fp) as 废品,';
s7:=s7+'sum(a1) as 炸瓷,sum(a1)*100/sum(rys) as 比率,';
s7:=s7+'sum(a2) as 爆花,sum(a2)*100/sum(rys) as 比率,';
s7:=s7+'sum(a3) as 断线,sum(a3)*100/sum(rys) as 比率,';
s7:=s7+'sum(a4) as 脏金,sum(a4)*100/sum(rys) as 比率,';
s7:=s7+'sum(a5) as 色脏,sum(a5)*100/sum(rys) as 比率,';
s7:=s7+'sum(a6) as 磕碰,sum(a6)*100/sum(rys) as 比率,';
s7:=s7+'sum(a8) as 白瓷过序,sum(a8)*100/sum(rys) as 比率,';
s7:=s7+'sum(a7) as 其它,sum(a7)*100/sum(rys) as 比率,';
大部分都相同,可以写到一条语句,不用重复赋值
 
使用了太多的Table和Query
很浪费太多内存,这不是一个好主意
最好是可以共用
一般使用2或者3个就差不多了
 
晕倒~~~
 
风格绝对有问题
[:D]
 
叮当猫:
有话就说,
晕倒可怎么办,
赶快上医院吗?
本来想听听高见的,
没想到把你晕倒了,

我是初手,
不要。。。。
 
我也想使用共享,
但实际上很多问题,
又各有不同,
你说怎么办?
如果非使用共享,
我感到对我的水平而言,
比这样处理难度还大!
各位如有好的方法或思想,
不妨指导一下,
先谢谢了,
叮当猫:
我感到你水平很高,
但德行不是很好啊,
难道你没有从小路上走过,
直接成为高手的????

 
我眼花了,
 
忘了, 系统提示的信息是:
‘capability not supported!’

大家分析一下是什么原因!
 
先为参数指定数据类型,再赋值。
query4.parambyname('rq1').Datatype:=ftDatetime;
query4.parambyname('rq1').asdate:=datetimepicker1.date;
 
你的这种方式不是很好,因为代码太乱了,而且Table和Query用的也太多了,如果不是必要
你完全可以用一个Query代替,我看你注释掉了代码好象是为了向表中插入数据,
这种情况用一个Query就可以了,另外你应该按功能将你的这段代码分成几个部分:
还有一点,就是写程序时尽量多写的注释,这样比较容易看懂
我没有你的数据库环境,不知道你具体错在哪,估计是SQL错,你可以象下面那样改一下语句,
在每个Query的Open或ExecSQL之前加上Clipboard.AsText :=SQL.Text;
然后执行,当出错后,打开SQL Exploer 将SQL粘到它里面执行,就能找到错误了

uses Clipbrd;

procedure TForm1.Button2Click(Sender: TObject);
begin
EmptyTable;
InsertTable;
end;

procedure TForm1.EmptyTable;
var
l_SQL : string; {保存SQL语句}
begin
with Query1 do
begin
Close;
{清空表1}
SQL.Text := 'delete from Table1';
Clipboard.AsText :=SQL.Text ;//将SQL粘到剪贴板
ExecSQL;

{清空表2}
SQL.Text := 'delete from table2';
Clipboard.AsText :=SQL.Text ;//将SQL粘到剪贴板
ExecSQL;

........
end;

end;

procedure TForm1.InsertTable;
var
l_SQL : string; {保存SQL语句}
begin
l_SQL := 'insert into cktjbb1(bz,cpmc,rys,yjp,yjl,hgs,hgl,dwp,fp,a1,l1,a2,l2,a3,l3,a4,l4,a5,l5,a6,l6,a7,l7,hj,l8,a8,l9) select bz,'
+ 'cpmc,sum(rys),sum(yjp),sum(yjp)*100/sum(rys),sum(hgs),sum(hgs)*100/sum(rys),sum(dwp),sum(fp),'
+ 'sum(a1),sum(a1)*100/sum(rys),sum(a2),sum(a2)*100/sum(rys),sum(a3),sum(a3)*100/sum(rys),'
+ 'sum(a4),sum(a4)*100/sum(rys),sum(a5),sum(a5)*100/sum(rys),asum(a6),sum(a6)*100/sum(rys),'
+ 'sum(a7),sum(a7)*100/sum(rys),sum(a1+a2+a3+a4+a5+a6+a7),sum(a1+a2+a3+a4+a5+a6+a7)*100/sum(rys),sum(a8),sum(a8)*100/sum(rys) '
+ 'from cpkck where (rq between :rq1 and :rq2) group by bz,cpmc';
with Query1 do
begin
Close;
SQL.Text := l_SQL;
ParamByName('rq1').AsDate := DateTimePicker1.Date;
ParamByName('rq2').AsDate := DateTimePicker2.Date;
Clipboard.AsText :=SQL.Text ;//将SQL粘到剪贴板
ExecSQL;
end;

l_SQL := '......';
with Query1 do
begin
Close;
SQL.Text :=l_SQL;
....

end;

.........
end;
 
忘了, 系统提示的信息是:
‘capability not supported!’
把你的BDE升级一下,或直接把高版本的BDE文件COPY到现在的BDE目录下

程序没问题

 
小草:
BDE 如何升级?
实际上出错案的地方就是向数据库插入数据的地方,
但究竟为什么错,不知道为什么,至少我也看到代码没有错误!
你说拷贝高版本的, D6的可以吧!怎么拷贝呢?拷贝哪些文件?
谢谢!



 
我认为和BDE 版本没有关系!

高手们请发言啊!
 
大家都找不到问题所在

建议你新建一个工程文件

然后把出问题的代码重新写一遍

放心

写过一遍的东西再写很快的

说不定就好了
 
谢谢各位了,问题我已经找到是如下代码写错了!
// s:=s+'sum(a4),sum(a4)*100/sum(rys),sum(a5),sum(a5)*100/sum(rys),asum(a6),sum(a6)*100/sum(rys),';
中的 asum(a6)

至于为什么使用如此多的query组件,
因为该软件中的一个 pagecontrol1 中共有个9个不同的页,
每页显示的数据不一样,

总之谢谢各位!
我会酌情分分,
还忘 yzhshi 大狭来领分!


 
既然yzhshi大侠不来领分,
我们就分了吧,
反正有这么多弟兄见证,不是我不愿意履行诺言!

 
为什么不在pagecontrol1 切换的时候变动SQL,可以少用几个query
查错的时候走走单步么,这么多代码眼都看花了~~~~
 
我也和顶楼的 朋友一样, 做过一个 有 9个 pagecontrol 程序.

( 94年 ..02年 )

但,我的数据处理和他不太一样.

我建立一个 Data Module ,一般的数据 操作 用到的 Qr , Tb, Datasrc等 ,

等 装那 那个 中,

而 9个 pagecontrol 都 是同样的 操作, 字段一样, 只是 表不一样(我的也一样

只是 在一个 数据表中 加入一个 pagecontrol 所属年的 标志. )

只是 字不一样, 等 , 可以用一个 Qr 就 安成, 哪不一样, 改哪个就好了.

当然, 对于你 已 完成的 代码, 不知你是不是还有 信心, 时间和 耐心 重整你的 代码

但, 希望你以后的 程序 中, 用 这个的 方法 试试.
 
谢谢几位真诚相助的朋友!
 
后退
顶部