Subject | Re: [IBO] problems with SQL query |
---|---|
Author | Helen Borrie |
Post date | 2004-07-29T10:30:38Z |
At 10:02 AM 29/07/2004 +0100, you wrote:
you are reading. AsString isn't incompatible with char types.
I note you are reading the Text property of a control named
DBEdit3. Assuming it is a TDBEdit, reading its Text property won't get the
correct type of data if it is not a character type. To get this value, you
have to read the underlying data field value. If you need it to go to the
database as a char(10), cast it with IntToStr before passing it to your
string parameter, or include a CAST() expression in your SQL statement.
Helen
>Hi HelenThis isn't an incompatibility coming from the databases, it's in the values
>
>As I use the qryFBall do several things I would like to have set the sql
>at run time, also both fields are strings. I thus changed the code to look
>like:
>
>queryString:='SELECT e.* FROM employee e JOIN project1 p1 ON p1.empNo =
>e.emp_no WHERE p1.empNo= :empNo and p1.projectno= :projectno'
>
>with datamodule2.qryFBAll do
> begin
> if not Prepared then Prepare;
> if Active then Close;
> Params['empNo'].AsString := form1.DBEdit3.Text;
> Params['projectno'].AsString :=form1.cmbModule.text;
> sql.Clear;
> sql.add(queryString);
> open;
> end;
>
>but I get 'incompatible types: integer and string' on both the params
>lines. The fields are both set to char(10) in the database
you are reading. AsString isn't incompatible with char types.
I note you are reading the Text property of a control named
DBEdit3. Assuming it is a TDBEdit, reading its Text property won't get the
correct type of data if it is not a character type. To get this value, you
have to read the underlying data field value. If you need it to go to the
database as a char(10), cast it with IntToStr before passing it to your
string parameter, or include a CAST() expression in your SQL statement.
Helen