How to get the mysql table id by a combobox

Asked

Viewed 328 times

0

My question is I have a combobox in the application and this combobox is filled with data coming from mysql database so far so good. I launch the data in a Datasource to feed the combobox but when the user chooses a combobox result as for example: Sector = FINANCIAL I want to record in the bank the financial sector Id and not the financial word. How can I catch this Id?

ParamByName('SETOR').AsString := SETOR.????????; ==> This is where my sector call combobox is.

  • Inform how combo data is loaded, as this influences the return of data.

  • I have a Tmyquery that does a select like this: with Query_sector of Begin Close; SQL.Clear; SQL.Add('SELECT * FROM tables_system_sector WHERE STATUS = 'A''); Open; &##Xa; while NOT Query_sector.Eof of Begin SECTOR.Items.Add(Query_sector['SECTOR']); Query_sector.Next; end; end; Then I have a: Tmydatasource that feeds this combobox.

1 answer

1

What you want is the behavior of Tdblookupcombobox. This allows you to call one datasource and to define the field that the user sees (Listfield) and the one that you will use (Keyfield).

But in your case you probably didn’t need a Tdblookupcombobox but a Tlookupcombobox, which as far as I know only with external components (I personally use those from Devexpress)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.