procedure Tzj_tj2_jxjy.BitBtn1Click(Sender: TObject); var a:integer; str1:string; str2:string; begin if datetimepicker1.Date >datetimepicker2.Date then showmessage('开始时间大于结束时间,请重新设置开始时间!'); end else begin str1:=copy(datetostr(datetimepicker1.Date),1,4); str2:=copy(datetostr(datetimepicker2.Date),1,4); end;
with q_jxjy do begin f1book1.ClearRange(-1,-1,1,1,f1clearall); f1book1.TextRC[1,1]:='工 号'; f1book1.TextRC[1,2]:='姓 名'; f1book1.TextRC[1,3]:='性 别'; f1book1.TextRC[1,4]:='总学时'; f1book1.TextRC[1,5]:='岗位名称'; f1book1.TextRC[1,6]:='部门名称';
close; sql.clear; sql.Add('select * from userid.zj_jxjyxxb where nf>=str1 and nf<=str2 and pass=1'); open;
a:=2; while not eof do begin f1book1.TextRC[a,1]:=fieldbyname('gh').asstring; f1book1.TextRC[a,2]:=fieldbyname('xm').asstring; f1book1.TextRC[a,3]:=fieldbyname('xb').asstring; f1book1.TextRC[a,4]:=fieldbyname('xs').asstring; f1book1.TextRC[a,5]:=fieldbyname('gwmc').asstring; f1book1.TextRC[a,6]:=fieldbyname('bmmc').asstring; a:=a+1; next; end; end end;
sql.Add('select * from userid.zj_jxjyxxb where nf>=str1 and nf<=str2 and pass=1'); 改为: sql.Add('select * from userid.zj_jxjyxxb where nf>= ' + str1 + ' and nf<=' + str2 + ' and pass=1');