Client端的法
procedure TFMHR52Y.BitBtn1Click(Sender: TObject);
begin
dtView2.Close;
DCQCClass3.Connected:=True;
DCQCClass3.AppServer.ChangeSql(MaskEdit1.Text+#13+MaskEdit2.Text);//是依时间区间输入
dtView2.Open;
end;
AP端的写法
procedure TClass1.ChangeSQL( const SearchValue: WideString);
var
AValueStringList,ByStringList:TStringList;
i,j,k:integer;
begin
AValueStringList:=TStringList.Create;
ByStringList:=TStringList.Create;
AValueStringList.Text:=SearchValue;
dtRP1501.Close;
//Reset SQL
for i:=dtRP1501.SQL.Count-1do
wnto 0do
if (pos('ORDER BY',UpperCase(dtRP1501.SQL))>0) or (pos('GROUP BY',UpperCase(dtRP1501.SQL))>0) then
begin
ByStringList.add(dtRP1501.SQL);
dtRP1501.SQL.Delete(i);
end;
for j:=dtRP1501.SQL.Count-1do
wnto 0do
if (Pos(' ',dtRP1501.SQL[j])<>0) and (Pos(' as ',dtRP1501.SQL[j])=0) then
dtRP1501.SQL.Delete(j);
if (AValueStringList[0]<>'') and (AValueStringList[0]<>'*') then
//dtView4.SQL.Add(' AND QCMTDT10.RemeltDATE='+sqldate1(AValueStringList[0],2));
dtRP1501.SQL.Add(' AND QCMTDT10.RemeltDATE='+''''+AValueStringList[0]+'''');
if ByStringList.count > 0 then
for k:= ByStringList.count-1do
wnto 0do
dtRP1501.SQL.Add(ByStringList[k]);
dtRP1501.Open;
end;