Recent

Author Topic: DBLookUpComboBox and 'invalid variant type cast'  (Read 8129 times)

rise_nak

  • New Member
  • *
  • Posts: 16
DBLookUpComboBox and 'invalid variant type cast'
« on: June 16, 2011, 10:03:18 pm »
Hello,
I'm trying to use DBLookUpComboBox to make something like a filter for a DBGrid.
I put DBLookUpComboBox1 on the form and on buttonclick I have the following code:

Code: [Select]
DBLookupComboBox1.DataSource := FormKraj.DataListaWalut;
  DBLookupComboBox1.DataField := 'SYMBOL_I_PANSTWO';
  DBLookupComboBox1.ListSource := FormKraj.DataListaWalut;
  DBLookupComboBox1.ListField := 'SYMBOL_I_PANSTWO';
  DBLookupComboBox1.KeyField := 'WAL_ID';
ListaWalutQuery.Open;

ListaWalutQuery is connected with DataListaWalut datasource.
I have also DGGrid with DataSource := DataListaWalut and everything is ok, so I think that a problem is somewhere in  DBLookupComboBox.
When I click button I got an error 'invalid variant type cast' , debugger shows that a problem is in function TDBLookup.ListFieldValue.
Than I got an error 'invalid value for field 'WAL_iD'' and debugger shows the same line.
List is filled by values from field SYMBOL_I_PANSTWO, as it should, but when I choose a position from list I  got the same error 'invalid variant type cast' and 'invalid value for field 'WAL_iD''.

Code: [Select]
ListaWalutQuery.SQL := 'SELECT a.*, a.WAL_SYMBOL||' - '||a.WAL_PANSTWO as SYMBOL_I_PANSTWO FROM WALUTY_TABELE a;'

What an i doing wrong?
« Last Edit: June 19, 2011, 04:23:19 pm by rise_nak »

woffleys

  • Newbie
  • Posts: 1
Re: DBLookUpComboBox and 'invalid variant type cast'
« Reply #1 on: December 30, 2011, 03:11:59 pm »
I have had the same problem, however, I have made a change to the code in dblookup.inc to fix this. if its not fixed, change

'VarArrayOf([AListFieldValue])' to 'AListFieldValue'

in

procedure TDBLookup.UpdateData(const AListFieldValue: string);

around line 392


 

TinyPortal © 2005-2018