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’
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’
解决方案 »
- 求助:哪位前辈有高程考试的资料,请给小弟传点,小弟在这里谢过了:)
- 不知哪些朋友有DELPHI的群号码?
- dbgrid中,按回车换行问题。
- CopyFileEx?
- installshield express for delphi的使用说明
- 求教query的sql问题
- 用Tadotable组件loadfromfile的数据怎么再写入原来的数据库表呢?
- 运行以下代码,第一次运行时可以实现添加和删除,但是第二次点击就出错,重新打开后点击就有可以实现相关的功能,求助?
- 如何将一个txt文件读到一个string中?
- 我真要改学 VC++ 吗?
- 紧急求救
- 懒惰的程序员:谁给个动态创建ODBC数据源的函数,要通用一点的,拷过来就能用,呵呵~~
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的值。
很容易看出错误的。
query1.ExecSQL;
table1.Refresh;
table1.First;
///////////////////////////////////////////
Table1.Close;
Table1.Open;
table的refresh我没用过,不过改成
table1.Close;
table1.Open;
肯定可以的。
我跟综时asql:='insert into 工资表(编号,姓名,日工资,出勤天数,奖金,安装费,工资年度,工资月份) select distinct 序号,姓名,日工资,25,0,0,2003,4 from 人员信息表.db',运行到table1.Refresh的时候;出现错误提示‘Type mismatch in expression’
改成
table1.Close;
table1.Open;
还是出错后停在这里?
如果是后者,那就是query1.ExecSQL;出的错。
如果是,就看不出问题了,
要不把table改成Query或者AdoQuery吧,
应该可以的。