procedure Tfrm_wage.btn_newClick(Sender: TObject);
var
  temp,asql:string;
  i:integer;date1,date2:tdatetime;
begin
 table1.Filter:='工资年度='+se_year.Text +' and 工资月份='+se_month.Text ;
  table1.Filtered:=true;
  if table1.RecordCount=0 then
  begin
    temp:='select distinct 序号,姓名,日工资,25,0,0,'+se_year.Text+','+se_month.text+' from 人员信息表.db';
     asql:='insert into 工资表(编号,姓名,日工资,出勤天数,奖金,安装费,工资年度,工资月份)  ' +
      ' select distinct 序号,姓名,日工资,25,0,0,'''+se_year.Text+''','''+se_month.text+''' from 人员信息表.db';
   query1.SQL.Text :=asql;
   query1.ExecSQL;
   table1.Refresh;
   table1.First;   for i:=0 to table1.recordcount-1 do
   begin
     query1.Close;
     query1.sql.Text:='select sum(安装费) from 安装记录表.db where 主安装人='''
          +table1.Fields[1].AsString+''''+' and 安装日期>=:d1 and 安装日期<:d2';    date1:=encodedate(se_year.Value,se_month.Value ,1);
    date2:=encodedate(se_year.Value,se_month.Value+1,1);
    query1.ParamByName('d1').AsDateTime:=date1;
    query1.ParamByName('d2').AsDateTime:=date2;
    query1.Open;    table1.Edit ;
    table1.FieldByName('安装费').AsFloat:=query1.Fields[0].AsFloat ;
    table1.Post ;
    table1.next;
end;end;
end;运行跟踪在table1.Refresh;这里时候,出现错误提示Type mismatch in expression’

解决方案 »

  1.   

    你的sql语句有问题吧.在你的另外一个问题里我做了回答.
      

  2.   

    你是设断点按f8跟踪的么?
    asql:='insert into 工资表(编号,姓名,日工资,出勤天数,奖金,安装费,工资年度,工资月份)  ' +
          ' select distinct 序号,姓名,日工资,25,0,0,'+se_year.Text+','+se_month.text+' from 人员信息表.db';去掉不必要的单引号试试,有可能se_year.text和se_month.text为空,那样会报错的。你在query1.ExecSQL;这里设个断点,然后看一下asql的值。
    很容易看出错误的。
      

  3.   

    query1.SQL.Text :=asql;
       query1.ExecSQL;
       table1.Refresh;
       table1.First;
    ///////////////////////////////////////////
    Table1.Close;
    Table1.Open;
      

  4.   

    是的,refresh这个方法经常出问题
    table的refresh我没用过,不过改成
    table1.Close;
    table1.Open;
    肯定可以的。
      

  5.   

    我跟综时asql:='insert into 工资表(编号,姓名,日工资,出勤天数,奖金,安装费,工资年度,工资月份) select distinct 序号,姓名,日工资,25,0,0,2003,4 from 人员信息表.db',运行到table1.Refresh;就保‘Type mismatch in expression’错
      

  6.   

    heixiu1980(迷茫ing) 兄,不是逗号不逗号的简单问题,我在说一下提示:
    我跟综时asql:='insert into 工资表(编号,姓名,日工资,出勤天数,奖金,安装费,工资年度,工资月份) select distinct 序号,姓名,日工资,25,0,0,2003,4 from 人员信息表.db',运行到table1.Refresh的时候;出现错误提示‘Type mismatch in expression’
      

  7.   

    把table1.refresh;
    改成
    table1.Close;
    table1.Open;
      

  8.   

    你指的“运行到table1.Refresh的时候”是单步跟踪到这里出错,
    还是出错后停在这里?
    如果是后者,那就是query1.ExecSQL;出的错。
      

  9.   

    指的是“运行到table1.Refresh的时候”是单步跟踪到这里出错后就停在这里
      

  10.   

    工资表里的工资年度和工资月份是int型的吧?
    如果是,就看不出问题了,
    要不把table改成Query或者AdoQuery吧,
    应该可以的。
      

  11.   

    "工资表里的工资年度和工资月份是int型的吧?" 是number型