Re:Help with ADOQuery and Parameters
Rich,
At design time set the SQL,
Select
MyFields
From
MyTable
Where
MyDatetimeField Between :StartDate and :EndDate
The parameters should contain StartDate and EndDate (with the correct type
information) and in code...
function TYourDataModule.LoadQueryObject(const StartDate, EndDate
:String):boolean;
with YourQueryComponent do
begin {Start of with query do}
try {Start of try...except block}
Close;
Parameters.ParamByName('StartDate').Value := StartDate;
Parameters.ParamByName('EndDate').Value := EndDate;
Open;
Result := NOT(IsEmpty);
except
on e: Exception do
begin
Close;
Result := False;
end;
end; {End of try...except block}
end; {End of with query do}
end;
Good luck,
krf
Quote
Richard Morey <rwmo...@27east.com> wrote in message
news:3c0eb40d$1_2@dnews...
Quote
> Hi..
> I am trying to build an application where the user enters two dates and I
> load a query from a text file into the ADOQuery
> and then pass the two dates the user entered into the SQL as parameters. I
> know this can be done but I've never
> tried anything like this so I thought I'd look for some one here to give
me
> a quick tutorial.
> Thanks
> Rich
> --
> ****************************
> Richard Morey
> WildEye Design
> "From Present to Presence"
> 1291 Pea Pond Road
> North Bellmore, NY 11710
> 516-679-2826 / 516-849-5248
> www.wildeye.net
> ****************************