当前位置:编程学习 > Delphi >>

delphi 删除临时表中内容

代码如下 procedure TForm1.Button1Click(Sender: TObject); var tbegin, tend: TDate; l,zint,cint,vstr, vSQL,sm,sj: String; i :real; j,k:integer; //cint : integer; begin tbegin := datetimepicker1.date; //datetimepicker1.date tend := datetimepicker2.date; //datetimepicker2.date while tbegin <= tend do begin vstr := FormatDateTime('yyyy', tbegin); sm := FormatDateTime('MM', tbegin); sj := FormatDateTime('YYYY-MM', tbegin); ADOQuery1.Close; ADOQuery1.SQL.Clear; vsql := ' delete from #tem '; ADOQuery1.SQL.Add(vsql); ADOQuery1.Active:=true; ////////在此报错,求解决方法~~~o(╯□╰)o ADOQuery1.Close; ADOQuery1.SQL.Clear; vsql := ' select count(*) as co from lmjzllfx where year(ghsj)='+vstr+'and month(ghsj)='+sm+''; tbegin := Incmonth(tbegin, 1); ADOQuery1.SQL.Add(vsql); ADOQuery1.Active:=true; cint :=adoquery1.fieldbyname('co').asstring; k := adoquery1.fieldbyname('co').asinteger; ADOQuery1.Close; ADOQuery1.SQL.Clear; vsql :='select count(*) as zs from lmjzllfx where ghsj>='''+datetostr(DateTimePicker1.Date)+''' and ghsj<= '''+datetostr(DateTimePicker2.Date)+''''; ADOQuery1.SQL.Add(vsql); ADOQuery1.Active:=true; //cint :=adoquery1.fieldbyname('co').asstring; j := adoquery1.fieldbyname('zs').asinteger; //k := adoquery1.fieldbyname('co').asinteger; i :=k/j; l :=floattostr(i); vsql :='insert into #tem (时间,人数,比例) values ('''+sj+''','+cint+','+l+')'; ADOQuery1.SQL.Add(vsql); ADOQuery1.Active:=true; ADOQuery1.Close; ADOQuery1.SQL.Clear; vsql :='select * from #tem'; ADOQuery1.SQL.Add(vsql); ADOQuery1.Active:=true; edit1.text:=vsql; end; end; procedure TForm1.Button2Click(Sender: TObject); begin application.Terminate; end; end.
追问:ADOQuery1.Active:=true;和ADOQuery1.ExecSql;  有啥区别?
答案:ADOQuery1.Active:=true;      ////////在此报错
改为
ADOQuery1.ExecSql;
其他:期待解答的人儿。。。。

上一个:delphi 这条语句请求更正
下一个:delphi dbgrid 排序

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,