Topic: Sql query and combo box

Hi

Just start to use MVD.
Great tool for rapid coding lite applications.

But I have a little problem.

I writing an SQL query. I want to use a field value from the form in this query.
I've understood that I need to use a special notation for that :
'{fieldName}'

When I want to use a combo box value in the query, the index of the value is return, not the value.
Is there a way to get the value of the combo box field ?

Tks.

Re: Sql query and combo box

Hi,

ComboBox return index of record id.

Usually there is no need to get the text value from the list.


To get the text value:
SELECT FirstName FROM persons where persons.id = {ComboBoxNames}


Please describe what you want to do, I'll try to help you.

Dmitry.

Re: Sql query and combo box

I have a table Category (Dictionary) => CatCode (Text) + CatName (Text).
The catCode is text  (CatA, catB,catC,...), not a number.

I have a table Item with a field type "Relationship" to Category (called id_Category).

I have a form to edit Item with a combobox to choose category.
This form have a button executing an SQL query displaying the count of item existing of the choosen category.

select count(*) from item i where i.id_Category = '{CbCategory}"

As you can see, "CatA" will never match an index value.

I can of course add an id field in the Category table. Maybe it's the only solution.

Re: Sql query and combo box

Ok, afert using SqLite Databse Browser, it seems all tables have an integer field named "id", which is primary key, and not shown in the database designer of MVD.

I suppose the relations ships are managed using this key.
So this is the answer of my question.

Re: Sql query and combo box

Yes, id is primary key, you can use this in SQL queries.

Dmitry.