with adoquery1 do
begin
close;
sql.clear;
sql.add('select * from Chanel');
open;
CNo:=fieldbyname('ChanelNO').asstring;
with adoquery2 do
begin
close;
sql.clear;
sql.add('select * from Powerdata where Date='+quotedstr(datetostr(date()) and ChanelNO=Cno);//就在这里不知怎么写,我要查询的是,当时间等于系统取值的时间,号码等于CNO这个号码时,就查询出来;这样是编译不过去的,我只是提供一个说明,
end;
end;
begin
close;
sql.clear;
sql.add('select * from Chanel');
open;
CNo:=fieldbyname('ChanelNO').asstring;
with adoquery2 do
begin
close;
sql.clear;
sql.add('select * from Powerdata where Date='+quotedstr(datetostr(date()) and ChanelNO=Cno);//就在这里不知怎么写,我要查询的是,当时间等于系统取值的时间,号码等于CNO这个号码时,就查询出来;这样是编译不过去的,我只是提供一个说明,
end;
end;
sql.add('select * from Powerdata where Date=:dt and ChanelNO='''+Cno+'''');//
Parameters.ParamByName('dt').Value := datetostr(date()) ;如果不行:dt 也加上单引号试试 ,不同数据库对字符串处理不一样。sql.add('select * from Powerdata where Date='':dt'' and ChanelNO='''+Cno+'''');
Parameters.ParamByName('dt').Value := datetostr(date()) ;
但这样就过了,运行没有问题,
sql.Add('select * from powerdata where [date]='+quotedstr(datetostr(date()))+' and ChanelNO='+quotedstr(Cno));