在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;
dtRP1201.Close;
//Reset SQL
for i:=dtRP1201.SQL.Count-1do
wnto 0do
if (pos('ORDER BY',UpperCase(dtRP1201.SQL))>0) or (pos('GROUP BY',UpperCase(dtRP1201.SQL))>0) then
begin
ByStringList.add(dtRP1201.SQL);
dtRP1201.SQL.Delete(i);
end;
for j:=dtRP1201.SQL.Count-1do
wnto 0do
if (Pos(' ',dtRP1201.SQL[j])<>0) and (Pos(' as ',dtRP1201.SQL[j])=0) then
dtRP1201.SQL.Delete(j);
if (AValueStringList[0]<>'') and (AValueStringList[0]<>'*') then
dtRP1201.SQL.Add(' AND PXM30.PDATE='''+AValueStringList[0]+'''');
if ByStringList.count > 0 then
for k:= ByStringList.count-1do
wnto 0do
dtRP1201.SQL.Add(ByStringList[k]);
dtRP1201.Open;
end;
在Client 就直接用Edit1.textEdit2.text和将字符串传出 DcomConenct.APP. .ChangeSQL(Edit1.text,Edit2.text)即可