for i:=0 to 8 do
begin
Query2.Active:=false;
Query2.SQL.Clear;
Query2.SQL.Text:='select A,B,C FROM DDD WHERE A=字符串(变化的数组,有具体的值)';
Query2.Active:=true;
end;
我想把循环的查询结果在DBGrid中显示出来,可以吗?
begin
Query2.Active:=false;
Query2.SQL.Clear;
Query2.SQL.Text:='select A,B,C FROM DDD WHERE A=字符串(变化的数组,有具体的值)';
Query2.Active:=true;
end;
我想把循环的查询结果在DBGrid中显示出来,可以吗?
要想显示到DBGRID中,只需数据源绑定就可以了!
Query2.SQL.Clear;
for i:=0 to 8 do
begin
Query2.SQL.Text:='select A,B,C FROM DDD WHERE A=字符串(变化的数组,有具体的值)';
end;
Query2.Active:=true;
Query2.SQL.Clear;
Query2.SQL.Text:='select A,B,C FROM DDD WHERE (a='+''''+字符串[0]+''''+')';
for i:=1 to 8 do
begin
Query2.SQL.add('OR (A='+''''+字符串[i]+''''+')');
end;
Query2.Active:=true;-_-!
这样var
S: string;
I: Integer;
begin
for I := 0 to 8 do S := ',' + QuotedStr(数组[I]);
if Length(S) = 0 then Exit; Query2.Close;
Query2.SQL.Text := 'select A,B,C FROM DDD WHERE A IN (' + S + ')';
Query2.Open;
end;
S: string;
I: Integer;
begin
for I := 0 to 8 do S := ',' + QuotedStr(数组[I]);
if Length(S) = 0 then Exit; Delete(S, 1, 1);
Query2.Close;
Query2.SQL.Text := 'select A,B,C FROM DDD WHERE A IN (' + S + ')';
Query2.Open;
end;