使用變體開放數組實現通用查詢(array of const)

procedure sqlQuery(query: tadoquery; Asql: string; params: array of const);
begin
  with query do
  begin
    close;
    sql.Clear;
    sql.Text := format(Asql, params);
    open;
  end;
end;

 

procedure TForm1.Button1Click(Sender: TObject);
begin
  sqlQuery(adoquery1, 'select * from t1 where name = %s or id = %d', [QuotedStr('1'), 2]);
end;

posted @ 2010-02-03 09:25  delphi中间件  阅读(207)  评论(0编辑  收藏  举报