Board index » delphi » EDB Engine Error

EDB Engine Error

Hi Folks,

I still have a problem with getting TQuery to work with a "Date" field :

I have the SQL as follows :

SELECT * FROM 'ORDER.DBF' WHERE DEL_DATE =:REFPARAM

And the button has the following code :

Begin
Query1.Active:=False;
Query1.Params[0].AsString:=Edit1.Text
Query1.Active:=True;
End;

I have also tried :

begin
  Query1.Active := false;
  Query1.ParamByName('Date').AsString := Edit1.Text;
  Query1.Active := true;
end;

The SQL Query looked like this :

SELECT * FROM 'ORDER.DBF' WHERE DEL_DATE =:Date

The TParams property in the query is set for a 'Date' field.  

Basically what I want to happen is when a user inputs a date into the Edit1
component and presses the button the Query will display the corresponding  
date/s in a TBGrid component.

At the moment I keep getting the following error :

"EDBEngine Error" "Expression in this field is the wrong type"

Thanks

Cheers

Wayne .T.
Gaborone, Botswana.
... Democracy: 3 wolves & a sheep voting on what's for lunch.
___ Viper v2.0 [0025]

 

Re:EDB Engine Error


Quote
WAYNE TALBOT wrote:

> Hi Folks,

> I still have a problem with getting TQuery to work with a "Date" field :

> I have the SQL as follows :

> SELECT * FROM 'ORDER.DBF' WHERE DEL_DATE =:REFPARAM

> And the button has the following code :

> Begin
> Query1.Active:=False;
> Query1.Params[0].AsString:=Edit1.Text
> Query1.Active:=True;
> End;

> I have also tried :

> begin
>   Query1.Active := false;
>   Query1.ParamByName('Date').AsString := Edit1.Text;
>   Query1.Active := true;
> end;

> The SQL Query looked like this :

> SELECT * FROM 'ORDER.DBF' WHERE DEL_DATE =:Date

> The TParams property in the query is set for a 'Date' field.

> Basically what I want to happen is when a user inputs a date into the Edit1
> component and presses the button the Query will display the corresponding
> date/s in a TBGrid component.

> At the moment I keep getting the following error :

> "EDBEngine Error" "Expression in this field is the wrong type"

> Thanks

> Cheers

> Wayne .T.
> Gaborone, Botswana.
> ... Democracy: 3 wolves & a sheep voting on what's for lunch.
> ___ Viper v2.0 [0025]

Wayne,

  If the field in the database is of type Date,Time, or Timestamp, you need to convert
the value in the edit field to a datetime type (which is actually a real type with the
integer part being the date and the decimal part being the time).  It is a bit tricky
working with dates and times, don't get frustrated if you don't get it at first.  If you
continue to have problems, email me and I'll send you a code snippet.

-Anthony DiAngelus
 dia...@intnet.net

Other Threads