2,496
社区成员
发帖
与我相关
我的任务
分享
procedure TForm1.Button4Click(Sender: TObject);
var
s:string;
begin
if trim(edit1.Text) <>'' then begin
if adoquery1.FieldList.IndexOf(edit1.Text)>=0 then begin {-如果ADOQUERY1中有edit1中输入的字段-}
{---提取adoquery1的SQL语-----}
s := UpperCase(adoquery1.sql.Text);
if Pos('WHERE',s)>0 then
s := Copy(s,1,Pos('WHERE',s)-1) else
if Pos('ORDER',s)>0 then
begin
s := Copy(s,1,Pos('ORDER',s)-1);
end;
StringGrid1.ColCount:=0;{这里默认为五列}
StringGrid1.RowCount:=0;{这里默认为五行}
with adoquery2 do begin
First;{---------------------加了这句}
while not eof do begin
adolook.Close;
adolook.SQL.Text:=s+' where '+trim(edit1.Text)+'='+QuotedStr(adoquery2.FieldValues[trim(edit1.Text)]);
adolook.open;
if not adolook.IsEmpty then begin
{重复时写StringGrid用作显示}
StringGrid1.ColCount:=Fields.Count;
{--标题只是举例你看--}
for i :=0 to Fields.Count-1 do
StringGrid1.Cells[i,0]:='a'+inttostr(i);
while not eof do begin
StringGrid1.RowCount:=StringGrid1.RowCount+1;
for i :=0 to StringGrid1.ColCount-1 do
StringGrid1.Cells[i,StringGrid1.RowCount-1]:=Fields[I].AsString;
next;
end;
end else begin
{导入的操作}
end;
next;
end;
end;
end;
end;
end;