Re: TADOQuery and Date fields problem



Yep.. That should work also ;)

On Thu, 16 Jun 2005 18:44:52 +0300, "Vitali Kalinin"
<vitkalinin@xxxxxxxxx> wrote:

>This should work:
>qryLookUp.SQL.Clear;
>qryLookUp.SQL.Add('SELECT * FROM table1 WHERE (DevID = :DevID) and
>(ServiceDateTime = :ServiceDateTime)');
>qryLookUp.Parameters.ParamByName('DevID').Value := intDevID;
>qryLookUp.Parameters.ParamByName('ServiceDateTime').Value := serviceDate;
>
>
>"Shannon Walker" <shannon.walker@xxxxxxxxxx> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ
>ÓÌÅÄÕÀÝÅÅ: news:42b19132@xxxxxxxxxxxxxxxxxxxxxxxxx
>> I tried the following:
>>
>> with qryLookUp.Parameters.AddParameter do begin
>> DataType := ftDateTime;
>> Direction := pdInput;
>> Name := 'SERVICE_DATE';
>> Value := serviceDate;
>> end;
>> qryLookUp.SQL.Add('SELECT * FROM ConcentratorRecords WHERE ((DevID = '+
>> IntToStr(intDevID) + ') and (ServiceDateTime = '+
>> qryLookUp.Parameters[0].Name + '))');
>>
>> But now when the query is run it says SERVICE_DATE doesn't have a default
>> value.
>>
>> I am not sure what I am doing wrong.
>>
>> "Opp" <nospam@xxxxxxxxxxxxxxx> wrote in message
>> news:9av2b1t3980ai8amnk3hb3r1lervqjjhj9@xxxxxxxxxx
>> > Here is a (brief) example of what that may look like..
>> >
>> > Here - IQ is the name of your ADO Query component..
>> >
>> >
>> > with IQ.Parameters.AddParameter do begin
>> > DataType := ftDateTime;
>> > Direction := pdInput;
>> > Name := 'ServiceDaeTime';
>> > Value := Date;
>> > end;
>> >
>> >
>> > Not Sure if setting the value in this way is correct - but you could
>> > try it.
>> >
>> > Paul.
>> >
>> >
>> >
>> >
>> > On Thu, 16 Jun 2005 08:24:58 -0400, "Shannon Walker"
>> > <shannon.walker@xxxxxxxxxx> wrote:
>> >
>> > >If I want to make my dateTime value a parameter in my query, what would
>> that
>> > >look like?
>> > >
>> > >
>> > >"Brian Bushay TeamB" <BBushay@xxxxxxxxx> wrote in message
>> > >news:ckn1b11k514rq2a4vutkvnujspv431e8a9@xxxxxxxxxx
>> > >> >I am using a TADOQuery in order to search through a table of records
>> for
>> > >a
>> > >> >date value. I can't seem to get the syntax right when specifying
>the
>> SQL
>> > >> >statement though. I have the following:
>> > >> >
>> > >> > qryLookUp.SQL.Add('SELECT * FROM table1 WHERE ((DevID = '+
>> > >> >IntToStr(intDevID) + ') and (ServiceDateTime = #' + serviceDate +
>'#'
>> > >> >+'))');
>> > >> >
>> > >> >serviceDate above is a string containing the date and time I am
>> looking
>> > >for.
>> > >> >ServiceDateTime DateTime field in MS Access.
>> > >> >
>> > >> >I get an error that says 'Parameter object is improperly defined'.
>> Does
>> > >> >anyone know the syntax for doing a search for a date value?
>> > >>
>> > >> Use a parameter in your query for the dateTimeValue
>> > >> Then set the value of the parameter.
>> > >> Or format you Time value to use "." instead of ":" as the separator
>and
>> > >drop the
>> > >> "#" characters just quote the dateTimevalue
>> > >>
>> > >>
>> > >>
>> > >> --
>> > >> Brian Bushay (TeamB)
>> > >> Bbushay@xxxxxxxxx
>> > >
>> >
>>
>>
>

.



Relevant Pages

  • Re: Identifying fields out of order
    ... Click on "Create Query in Design View" ... tblSeq AS Prev, tblSeq AS Next; ... Our SQL now would look like: ...
    (microsoft.public.access.queries)
  • Re: numbers query
    ... >| Thanks Don but how can I fit it in with the SQL already ... >| Thanks Paul M ... >|>amount up to a certain amount, ...
    (microsoft.public.frontpage.client)
  • Re: replace of DCount function
    ... Post the SQL of the query that you're using right now. ... <MS ACCESS MVP> ... "paul" wrote in message ...
    (microsoft.public.access.formscoding)
  • Re: TADOQuery and Date fields problem
    ... >> But now when the query is run it says SERVICE_DATE doesn't have a ... >>> Paul. ... >> SQL ... Prev by Date: ...
    (borland.public.delphi.database.ado)
  • Re: Internal Query Processor Error
    ... SQL Server MVP ... "Timothy" wrote in message ... > Hi Paul ... "Internal Query Processor Error: The ...
    (microsoft.public.sqlserver.programming)