代码如下:
adoquery1.close;
adoquery1.sql.clear;
adoqueyr1.sql.add('select sum(要素) as sum from table where 时间 between date1 and date2 and id=12);
adoquery1.open;
r:=adoquery1.fieldbyname('sum).asstring; path:=extractfilepath(application.exename);
assignfile(f,path+'test.txt');
rewrite(f);
writeln(f,r);
closefile(f);报警信息: Illegal type in write/writeln statement;
adoquery1.close;
adoquery1.sql.clear;
adoqueyr1.sql.add('select sum(要素) as sum from table where 时间 between date1 and date2 and id=12);
adoquery1.open;
r:=adoquery1.fieldbyname('sum).asstring; path:=extractfilepath(application.exename);
assignfile(f,path+'test.txt');
rewrite(f);
writeln(f,r);
closefile(f);报警信息: Illegal type in write/writeln statement;
var
F:textfile;
r:string;
path:string;
begin
r:=adoquery1.fieldbyname('sum').asstring;
path:=extractfilepath(application.exename)+'test.txt';
AssignFile(F,path);
if FileExists(path) then
begin
ReSet(F);
Append(F);
end
else
begin
ReWrite(F);
end;
writeln(f,r);
closefile(f);
end;