Board index » delphi » To Jeff: IBX 4.6 bug with TDBLookupComboBox?

To Jeff: IBX 4.6 bug with TDBLookupComboBox?

Hi Jeff,
Take a look at this piece of code (this is an example):
---
procedure TForm1.Edit1Exit(Sender: TObject);
     with ibquery2 do
     begin
       sql.clear;
       sql.add('select f_nome from fornecedores01 where f_numero = :c0');
       params[0].AsString := '00000001';
       open;
       if recordcount <> 0 then
         dbl1.keyvalue := trim(fieldbyname('f_nome').asstring)
       else showmessage('Does not exist');
       close;
     end;
end;
---

The table FORNECEDORES01 have 2 records:
  Record n.1:
    f_numero: '00000001'
    f_nome: 'Carlos Matos'
  Record n.2:
    f_numero: '00000002'
    f_nome: 'Frederic Mason'

The TDBLookupComboBox is as follows:
  TDBLookupComboBox.KeyField := 'f_nome';
TDBLookupComboBox.ListField := 'f_nome;f_numero';
TDBLookupComboBox.ListFieldIndex := 0;

The problem is that when I assign the value '00000001' or other to
dbl1.keyvalue, it should appear in the TDBLookupComboBox 'Carlos Matos' and
so on, but it appears blank. The result is the same if I use a TEdit to pass
the value. This works like it should if I assign the value without the TRIM
function, but with a TEdit I can't do this unless I put spaces to the end of
the TEdit until it matches the length of the field in the database (f_nome
char(40). This is ocurring to me after I installed IBX 4.6 and later
updates. This worked fine with IBX 4.52, I tested myself.
What's wrong?

Regards,
Carlos Matos

--

----------------------------------------------------------------------------
---
Morada / Address:
Urb.Vale Verde Lote 34 - Loja - 3040 COIMBRA
Telefone / Phone: 239 802 340/1/2/3/4/5/6/7/8
Fax: 293 802 349
E-mail: ma...@comograma.pt

 

Re:To Jeff: IBX 4.6 bug with TDBLookupComboBox?


Quote
Carlos Matos wrote:

> Hi Jeff,

        I'm not Jeff, but...

        Take a look at Jeff's message in the thread, "D6 Master Detail IBQuery
not synced" from 17 July 2001.  See if the code fix he gives there
eliminates the problem.  This sounds like the TFieldDataLink bug
(re)introduced in D6.

Quote
>        if recordcount <> 0 then

        BTW, as a general rule, don't ever use RecordCount in a C/S
application.  The very notion of a "record count" is something of a
falicy unless you're using a SNAPSHOT transaction.  What you want here
is the TDataset.IsEmpty property.

        HTH,

        -Craig

Re:To Jeff: IBX 4.6 bug with TDBLookupComboBox?


Is this key field a Char data type?  Sounds like you want it to be treated like
a VarChar.  Try setting the FixedChar to false for the field.  As I said in the
ReadMe, Char fields are now correctly created as FixedChar TFields as of 4.6.

Quote
Carlos Matos wrote:

> Hi Jeff,
> Take a look at this piece of code (this is an example):
> ---
> procedure TForm1.Edit1Exit(Sender: TObject);
>      with ibquery2 do
>      begin
>        sql.clear;
>        sql.add('select f_nome from fornecedores01 where f_numero = :c0');
>        params[0].AsString := '00000001';
>        open;
>        if recordcount <> 0 then
>          dbl1.keyvalue := trim(fieldbyname('f_nome').asstring)
>        else showmessage('Does not exist');
>        close;
>      end;
> end;
> ---

> The table FORNECEDORES01 have 2 records:
>   Record n.1:
>     f_numero: '00000001'
>     f_nome: 'Carlos Matos'
>   Record n.2:
>     f_numero: '00000002'
>     f_nome: 'Frederic Mason'

> The TDBLookupComboBox is as follows:
>   TDBLookupComboBox.KeyField := 'f_nome';
> TDBLookupComboBox.ListField := 'f_nome;f_numero';
> TDBLookupComboBox.ListFieldIndex := 0;

> The problem is that when I assign the value '00000001' or other to
> dbl1.keyvalue, it should appear in the TDBLookupComboBox 'Carlos Matos' and
> so on, but it appears blank. The result is the same if I use a TEdit to pass
> the value. This works like it should if I assign the value without the TRIM
> function, but with a TEdit I can't do this unless I put spaces to the end of
> the TEdit until it matches the length of the field in the database (f_nome
> char(40). This is ocurring to me after I installed IBX 4.6 and later
> updates. This worked fine with IBX 4.52, I tested myself.
> What's wrong?

> Regards,
> Carlos Matos

> --

> ----------------------------------------------------------------------------
> ---
> Morada / Address:
> Urb.Vale Verde Lote 34 - Loja - 3040 COIMBRA
> Telefone / Phone: 239 802 340/1/2/3/4/5/6/7/8
> Fax: 293 802 349
> E-mail: ma...@comograma.pt

--
Jeff Overcash (TeamB)   I don't think there are any Russians
(Please do not email    And there ain't no Yanks
 me directly unless     Just corporate criminals
 asked.  Thank You)     Playing with tanks.  (Michael Been)

Re:To Jeff: IBX 4.6 bug with TDBLookupComboBox?


Jeff,
I do not have TFields on this matter, so I can't set FixedChar to False.
Yes, the key field is a char datatype length 40.
But I guess you don't understand me very well. I'm going to try to explain
my self a little bit.
The query linked to the DataSource linked to the TDBLookupComboBox is not
empty, the 2 records from my example are showned when I dropdown the combox.
What I am saying is that when I assign values to TDBLookupComboBox.KeyValue,
it should appear on the combobox 'Carlos Matos' for KeyValue = 'Carlos
Matos' and 'Frederic Mason' for KeyValue = 'Frederic Mason', if this values
exist on the query for the given key F_NOME. For this work like it was
expected I must now, with IBX 4.6, instead of 'Carlos Matos', pass 'Carlos
Matos                            ' and so on. This wasn't necessary with IBX
4.52. On my application I have many cases like these, using TEdit's.

"Jeff Overcash (TeamB)" <overc...@onramp.net> escreveu na mensagem
news:3B69A419.93F6E213@onramp.net...

Quote
> Is this key field a Char data type?  Sounds like you want it to be treated
like
> a VarChar.  Try setting the FixedChar to false for the field.  As I said
in the
> ReadMe, Char fields are now correctly created as FixedChar TFields as of
4.6.

> Carlos Matos wrote:

> > Hi Jeff,
> > Take a look at this piece of code (this is an example):
> > ---
> > procedure TForm1.Edit1Exit(Sender: TObject);
> >      with ibquery2 do
> >      begin
> >        sql.clear;
> >        sql.add('select f_nome from fornecedores01 where f_numero =
:c0');
> >        params[0].AsString := '00000001';
> >        open;
> >        if recordcount <> 0 then
> >          dbl1.keyvalue := trim(fieldbyname('f_nome').asstring)
> >        else showmessage('Does not exist');
> >        close;
> >      end;
> > end;
> > ---

> > The table FORNECEDORES01 have 2 records:
> >   Record n.1:
> >     f_numero: '00000001'
> >     f_nome: 'Carlos Matos'
> >   Record n.2:
> >     f_numero: '00000002'
> >     f_nome: 'Frederic Mason'

> > The TDBLookupComboBox is as follows:
> >   TDBLookupComboBox.KeyField := 'f_nome';
> > TDBLookupComboBox.ListField := 'f_nome;f_numero';
> > TDBLookupComboBox.ListFieldIndex := 0;

> > The problem is that when I assign the value '00000001' or other to
> > dbl1.keyvalue, it should appear in the TDBLookupComboBox 'Carlos Matos'
and
> > so on, but it appears blank. The result is the same if I use a TEdit to
pass
> > the value. This works like it should if I assign the value without the
TRIM
> > function, but with a TEdit I can't do this unless I put spaces to the
end of
> > the TEdit until it matches the length of the field in the database
(f_nome
> > char(40). This is ocurring to me after I installed IBX 4.6 and later
> > updates. This worked fine with IBX 4.52, I tested myself.
> > What's wrong?

> > Regards,
> > Carlos Matos

> > --

> --------------------------------------------------------------------------
--
> > ---
> > Morada / Address:
> > Urb.Vale Verde Lote 34 - Loja - 3040 COIMBRA
> > Telefone / Phone: 239 802 340/1/2/3/4/5/6/7/8
> > Fax: 293 802 349
> > E-mail: ma...@comograma.pt

> --
> Jeff Overcash (TeamB)   I don't think there are any Russians
> (Please do not email    And there ain't no Yanks
>  me directly unless     Just corporate criminals
>  asked.  Thank You)     Playing with tanks.  (Michael Been)

Re:To Jeff: IBX 4.6 bug with TDBLookupComboBox?


I understand correctly.  You have defined a Char data type.  Char data types are
right padded.  Until 4.6 IBX incorrectly stripped the right side (and in some
cases corrupted the returned data).  If you set the TFields FixedChar to false
it should strip it like it did before.  Since you don't have TFields defined it
will be set true based on the data type.  If you want VarChar behavior you
should be defining your columns as VarChars though.

Quote
Carlos Matos wrote:

> Jeff,
> I do not have TFields on this matter, so I can't set FixedChar to False.
> Yes, the key field is a char datatype length 40.
> But I guess you don't understand me very well. I'm going to try to explain
> my self a little bit.
> The query linked to the DataSource linked to the TDBLookupComboBox is not
> empty, the 2 records from my example are showned when I dropdown the combox.
> What I am saying is that when I assign values to TDBLookupComboBox.KeyValue,
> it should appear on the combobox 'Carlos Matos' for KeyValue = 'Carlos
> Matos' and 'Frederic Mason' for KeyValue = 'Frederic Mason', if this values
> exist on the query for the given key F_NOME. For this work like it was
> expected I must now, with IBX 4.6, instead of 'Carlos Matos', pass 'Carlos
> Matos                            ' and so on. This wasn't necessary with IBX
> 4.52. On my application I have many cases like these, using TEdit's.

--
Jeff Overcash (TeamB)   I don't think there are any Russians
(Please do not email    And there ain't no Yanks
 me directly unless     Just corporate criminals
 asked.  Thank You)     Playing with tanks.  (Michael Been)

Other Threads