使用變體開放數組實現通用查詢(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;

你可能感兴趣的:(array)