1 (edited by iwkom 2022-04-08 18:19:42)

Topic: combobox value (solved)

I want to select a database entry in the combobo by default, but I make a mistake somewhere.

newprod.ComboBox3.dbItemID :=  SQLExecute('SELECT id FROM slujiteli WHERE Default = '+ newprod.CheckBox1.sqlValue +'');

Re: combobox value (solved)

Maybe the query returns an array. I'm thinking Combobox3 list is from slujiteli table, right?  The details you gave is a little bit vague for we don't know the Checkbox1's sqlValue, etc. For starter, maybe your select query returns an array. Try adding LIMIT 1 in your query.

newprod.ComboBox3.dbItemID :=  SQLExecute('SELECT id FROM slujiteli WHERE Default = '+ newprod.CheckBox1.sqlValue +' LIMIT 1');

My advice, try debugging it by checking the newprod.CHeckbox1.sqlvalue, then run the query from a third party sqlite viewer to check if it really returns the correct id you are getting from database. It is also easier to work on it if you can send a simple application that address to your query.

brian

Re: combobox value (solved)

I have a table with employees in which there is only one record.

The request is executed when the form is displayed and this error appears:

Near Default: Syntax error

4 (edited by sparrow 2022-04-08 16:31:20)

Re: combobox value (solved)

Hi all,
You chose the name Default very badly.
https://www.sqlite.org/lang_keywords.html
Change the field name to something else, or change it to "Default" in the query.

newprod.ComboBox3.dbItemID :=  SQLExecute('SELECT id FROM slujiteli WHERE "Default" = '+ newprod.CheckBox1.sqlValue +'');

If you want to use a keyword as a name, you need to quote it. There are four ways of quoting keywords in SQLite:

    'keyword'        A keyword in single quotes is a string literal.
    "keyword"        A keyword in double-quotes is an identifier.
    `keyword`        A keyword enclosed in grave accents (ASCII code 96) is an identifier. This is not standard SQL. This quoting mechanism is used by MySQL and is included in SQLite for compatibility.

Re: combobox value (solved)

sparrow wrote:

You chose the name Default very badly.
Change the field name to something else, or change it to "Default" in the query.

It was so simple!
This is part of a big project for me and who can think of it?

Many thanks.