General tips/hints:
1) In MS Access
min
and
max
is the name of function. It is strongly recommended to not use it as a name of fields, because some of words (for example
type
,
table
) are reserved words.
SQL Reserved Words (Access Developer Reference[
^]
Problem names and reserved words in Access[
^]
2) Do not concatenate query string in code. Use parameters!
PARAMETERS Declaration (Microsoft Access SQL)[
^]
Everything About Using Parameters from Code (ADO & ADODB)[
^]
Finally, your query should looks like:
Parameters [myVal] Integer
SELECT modelname
FROM [table]
WHERE [type]='gate' and [min]<=[myVal] and [max]>=[myVal]
But, as i mentioned above, i would strongly recommend you to change the name of fields!
How to call above query? Have a look at
OleDbCommand.Parameters[
^] property.