age1,age2:integer;
age1:=strtoint(edit16.Text);
age2:=strtoint(edit17.Text);sql_temp:='select * from viw_health  where stuage>='+age1+' and stuage<='+age2+' and time=#'+time_temp+'#';
       adoquery3.SQL.Add(sql_temp);
       adoquery3.Open;执行错误“[Error] UntMain.pas(818): Incompatible types: 'String' and 'Integer'”
请问这里 stuage>='+age1+' and stuage<='+age2+' 该这样写?

解决方案 »

  1.   

    sql_temp:='select * from viw_health  where stuage>='+IntToStr(age1)+' and stuage<='+IntToStr(age2)+' and time=#'+time_temp+'#';
    或者不要画蛇添足,直接
    sql_temp:='select * from viw_health  where stuage>='+edit16.Text+' and stuage<='+edit17.Text+' and time=#'+time_temp+'#';
      

  2.   

    Access: 
    adoquery3.sql.add('select * from viw_health where stuage>='+inttostr(age1)+' and stuage<='+inttostr(age2)+' and time=#'+time_temp+'#');
    MS SQL: 
    adoquery3.sql.add('select * from viw_health where stuage>='+inttostr(age1)+' and stuage<='+inttostr(age2)+' and time='''+timetostr(time_temp)+'''');
      

  3.   

    stuage我在数据库里定义为数字型的