Article View: borland.public.delphi.database
Article #2008Re: SQL property-set at run time-dates
From: Torsten Seemann
Date: Tue, 16 Mar 1999 00:00
Date: Tue, 16 Mar 1999 00:00
64 lines
2270 bytes
2270 bytes
Hi Paul.
Use the Params property of the TQuery component, like this:
Start by setting the SQL statement to:
'SELECT * FROM AIRCRAFT WHERE TYPE=:Type'
This will create a parameter in the Params list named 'Type'.
Change the type of the parameter to date and use the following statement to
set the value before executing the query:
Query.Params.ParamByName('Type').AsDateTime := Now
or
Query.Params.ParamByName('Type').AsString := '01/01/99'
This way, the conversion to the actual date format required by the SQL
server is done by BDE. All you have to care about is setting the
value of the parameter.
Hope that helps.
Regards,
Torsten Seemann
Paul Day <paul@pday.freeserve.net.uk> wrote in message
news:7cjnlk$7b9$1@news5.svr.pol.co.uk...
>Hi
>I am using buttonclick events to set the SQL property of a Query object at
>run time. This will display the records I require depending on the
>parameters of the statement.
>I have no problem with say :
>
>Query1.SQL.Add ('SELECT * FROM aircraft where type=Sea king');
>
>aircraft being my record table and type being one of the fields.
>
>However... another of the fields in the table is a date field, and I need
to
>display records in response to the user typing in a date in an Edit box and
>use this date as the WHERE. ie
>
>Query1.SQL.Add ('SELECT * FROM aircraft WHERE built = Edit1.Text');
>
>This of course does not work but neither does anything I Try....Can anyone
>help,
>I must be mixing things up and missing a simple point..
>Im using Delpi2.
>
>Paul
>
>
>
>
>
>
>
>
Technical Details
Message-ID:
<cCzH2.797$74.1371@news030.image.dk>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<7cjnlk$7b9$1@news5.svr.pol.co.uk>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 115d96,c04ca33623416bb0 X-Google-Attributes: gid115d96,public From: "Torsten Seemann" <ts@winddata.dk> Subject: Re: SQL property-set at run time-dates Date: 1999/03/16 Message-ID: <cCzH2.797$74.1371@news030.image.dk> X-Deja-AN: 455756287 References: <7cjnlk$7b9$1@news5.svr.pol.co.uk> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.0810.800 X-Complaints-To: news-abuse@image.dk X-Trace: news030.image.dk 921617928 194.234.60.42 (Tue, 16 Mar 1999 21:58:48 MET) X-MSMail-Priority: Normal NNTP-Posting-Date: Tue, 16 Mar 1999 21:58:48 MET Newsgroups: borland.public.delphi.database